domingo, 22 de fevereiro de 2009

VIM: verificador de sintaxe python.

Instalar PyChecker:

sudo python setup.py install

Em seguida, instalar PyLint:

sudo python setup.py install

Adicionar ao .vimrc:

function PythonGrep(tool)
set lazyredraw
" Close any existing cwindows.
cclose
let l:grepformat_save = &grepformat
let l:grepprogram_save = &grepprg
set grepformat&vim
set grepformat&vim
let &grepformat = '%f:%l:%m'
if a:tool == "pylint"
let &grepprg = 'pylint --output-format=parseable --reports=n'
elseif a:tool == "pychecker"
let &grepprg = 'pychecker --quiet -q'
else
echohl WarningMsg
echo "PythonGrep Error: Unknown Tool"
echohl none
endif
if &readonly == 0 | update | endif
silent! grep! %
let &grepformat = l:grepformat_save
let &grepprg = l:grepprogram_save
let l:mod_total = 0
let l:win_count = 1
" Determine correct window height
windo let l:win_count = l:win_count + 1
if l:win_count <= 2 | let l:win_count = 4 | endif windo let l:mod_total = l:mod_total + winheight(0)/l:win_count | \ execute 'resize +'.l:mod_total " Open cwindow execute 'belowright copen '.l:mod_total nnoremap c :cclose
set nolazyredraw
redraw!
endfunction

if ( !hasmapto('PythonGrep(pylint)') && (maparg('') == '') )
map :call PythonGrep('pylint')
map! :call PythonGrep('pylint')
else
if ( !has("gui_running") || has("win32") )
echo "Python Pylint Error: No Key mapped.\n".
\ " is taken and a replacement was not assigned."
endif
endif

if ( !hasmapto('PythonGrep(pychecker)') && (maparg('') == '') )
map :call PythonGrep('pychecker')
map! :call PythonGrep('pychecker')
else
if ( !has("gui_running") || has("win32") )
echo "Python Pychecker Error: No Key mapped.\n".
\ " is taken and a replacement was not assigned."
endif
endif

Criar o plugin pychecker.vim e adicionar:

" Vim compiler file
" Compiler: Pychecker for Python
if exists("current_compiler")
finish
endif
let current_compiler = "pychecker"
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal
endif

CompilerSet makeprg=pychecker\ --quiet\ %
CompilerSet efm=%f:%l:%m


Fonte: http://vim.wikia.com/wiki/Integrate_Pylint_and_Pychecker_support

Nenhum comentário:

Postar um comentário