From 4126760bca6c7c9686b55acc77a0390afd1ae046 Mon Sep 17 00:00:00 2001 From: Artem Nezvigin Date: Sat, 1 Dec 2012 12:17:46 -0800 Subject: [PATCH] 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. --- syntax_checkers/python.vim | 2 +- syntax_checkers/python/python.vim | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 syntax_checkers/python/python.vim diff --git a/syntax_checkers/python.vim b/syntax_checkers/python.vim index 863e0642..2261cad8 100644 --- a/syntax_checkers/python.vim +++ b/syntax_checkers/python.vim @@ -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') diff --git a/syntax_checkers/python/python.vim b/syntax_checkers/python/python.vim new file mode 100644 index 00000000..d58271fb --- /dev/null +++ b/syntax_checkers/python/python.vim @@ -0,0 +1,27 @@ +"============================================================================ +"File: python.vim +"Description: Syntax checking plugin for syntastic.vim +"Author: Artem Nezvigin +" +" `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