Add python checker that uses python itself

The advantage to this is that no 3rd party modules are required. People
new to Python probably won't have flake8/pyflakes/pylint installed. This
will get them basic syntax checking (no linting) out of the box.
This commit is contained in:
Artem Nezvigin 2012-12-01 12:17:46 -08:00
parent 122e88b82a
commit 4126760bca
2 changed files with 28 additions and 1 deletions

View File

@ -23,5 +23,5 @@ if !exists('g:syntastic_python_checker_args')
let g:syntastic_python_checker_args = ''
endif
let s:supported_checkers = ["flake8", "pyflakes", "pylint"]
let s:supported_checkers = ["flake8", "pyflakes", "pylint", "python"]
call SyntasticLoadChecker(s:supported_checkers, 'python')

View File

@ -0,0 +1,27 @@
"============================================================================
"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
"
"============================================================================
function! SyntaxCheckers_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