syntastic/syntax_checkers/python/python.vim
Martin Grenfell 16424e5761 add guards to all checkers
goddamn I love macros
2013-02-21 15:50:41 +00:00

40 lines
1.3 KiB
VimL

"============================================================================
"File: python.vim
"Description: Syntax checking plugin for syntastic.vim
"Author: Artem Nezvigin <artem at artnez dot com>
"
" `errorformat` derived from:
" http://www.vim.org/scripts/download_script.php?src_id=1392
"
"============================================================================
if exists("g:loaded_syntastic_python_python_checker")
finish
endif
let g:loaded_syntastic_python_python_checker=1
function! SyntaxCheckers_python_python_IsAvailable()
return executable('python')
endfunction
function! SyntaxCheckers_python_python_GetLocList()
let l:path = shellescape(expand('%'))
let l:cmd = "compile(open(" . l:path . ").read(), " . l:path . ", 'exec')"
let l:makeprg = 'python -c "' . l:cmd . '"'
let l:errorformat =
\ "\%A\ \ File\ \"%f\"\\\,\ line\ %l\\\,%m," .
\ "\%C\ \ \ \ %.%#," .
\ "\%+Z%.%#Error\:\ %.%#," .
\ "\%A\ \ File\ \"%f\"\\\,\ line\ %l," .
\ "\%+C\ \ %.%#," .
\ "\%-C%p^," .
\ "\%Z%m," .
\ "\%-G%.%#"
return SyntasticMake({ 'makeprg': l:makeprg, 'errorformat': l:errorformat })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'python',
\ 'name': 'python'})