syntastic/syntax_checkers/python/pylint.vim
LCD 47 3694908d05 Registry cleanup, stage 2.
(1) Checkers now have an _exec attribute, and an accessor getExec().
(2) CreateAndRegisterChecker() initializes _exec from an optional argument
'exec'.  If this argument is missing, 'name' is used instead.
(3) Functions SyntaxCheckers_*_IsAvailable() are now dictionary functions.
(4) Functions SyntaxCheckers_*_IsAvailable() are now optional.  When
they are missing, they are assumed to return executable(expand(self.getExec())).
(5) Argument 'exe' of function syntastic#makeprg#build() is now optional.
If this argument is missing, expand(self.getExec()) is used to set checker
executables.
2013-11-02 10:44:06 +02:00

69 lines
2.3 KiB
VimL

"============================================================================
"File: pylint.vim
"Description: Syntax checking plugin for syntastic.vim
"Author: Parantapa Bhattacharya <parantapa at gmail dot com>
"
"============================================================================
if exists("g:loaded_syntastic_python_pylint_checker")
finish
endif
let g:loaded_syntastic_python_pylint_checker = 1
let s:pylint_new = -1
function! SyntaxCheckers_python_pylint_IsAvailable() dict
let exe = self.getExec()
let s:pylint_new = executable(exe) ? s:PylintNew(exe) : -1
return s:pylint_new >= 0
endfunction
function! SyntaxCheckers_python_pylint_GetLocList() dict
let makeprg = syntastic#makeprg#build({
\ 'exe': 'pylint',
\ 'args': (s:pylint_new ? '--msg-template="{path}:{line}: [{msg_id}] {msg}" -r n' : '-f parseable -r n -i y'),
\ 'checker': self })
let errorformat =
\ '%A%f:%l: %m,' .
\ '%A%f:(%l): %m,' .
\ '%-Z%p^%.%#,' .
\ '%-G%.%#'
let loclist=SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'postprocess': ['sort'] })
for n in range(len(loclist))
let type = loclist[n]['text'][1]
if type =~# '\m^[EF]'
let loclist[n]['type'] = 'E'
elseif type =~# '\m^[CRW]'
let loclist[n]['type'] = 'W'
else
let loclist[n]['valid'] = 0
endif
let loclist[n]['vcol'] = 0
endfor
return loclist
endfunction
function! s:PylintNew(exe)
try
" On Windows the version is shown as "pylint-script.py 1.0.0".
" On Gentoo Linux it's "pylint-python2.7 0.28.0". Oh, joy. :)
let pylint_version = filter(split(system(a:exe . ' --version'), '\m, \=\|\n'), 'v:val =~# ''\m^pylint\>''')[0]
let pylint_version = substitute(pylint_version, '\v^\S+\s+', '', '')
let ret = syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(pylint_version), [1])
catch /^Vim\%((\a\+)\)\=:E684/
call syntastic#util#error("checker python/pylint: can't parse version string (abnormal termination?)")
let ret = -1
endtry
return ret
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'python',
\ 'name': 'pylint' })