2012-02-20 05:20:48 -05:00
|
|
|
"============================================================================
|
|
|
|
"File: pylint.vim
|
|
|
|
"Description: Syntax checking plugin for syntastic.vim
|
|
|
|
"Author: Parantapa Bhattacharya <parantapa at gmail dot com>
|
|
|
|
"
|
|
|
|
"============================================================================
|
2013-02-21 10:50:41 -05:00
|
|
|
if exists("g:loaded_syntastic_python_pylint_checker")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let g:loaded_syntastic_python_pylint_checker=1
|
|
|
|
|
2013-01-23 19:01:30 -05:00
|
|
|
function! SyntaxCheckers_python_pylint_IsAvailable()
|
|
|
|
return executable('pylint')
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! SyntaxCheckers_python_pylint_GetLocList()
|
2013-08-07 05:01:45 -04:00
|
|
|
let pylint_new = s:PylintNew()
|
|
|
|
|
2013-01-20 06:07:05 -05:00
|
|
|
let makeprg = syntastic#makeprg#build({
|
2013-05-10 07:11:07 -04:00
|
|
|
\ 'exe': 'pylint',
|
2013-08-07 05:01:45 -04:00
|
|
|
\ 'args': (pylint_new ? '--msg-template="{path}:{line}: [{msg_id}] {msg}" -r n' : '-f parseable -r n -i y'),
|
2013-05-31 14:05:45 -04:00
|
|
|
\ 'filetype': 'python',
|
2013-05-10 07:11:07 -04:00
|
|
|
\ 'subchecker': 'pylint' })
|
2013-05-31 14:05:45 -04:00
|
|
|
|
2013-04-10 04:48:17 -04:00
|
|
|
let errorformat =
|
2013-08-07 05:01:45 -04:00
|
|
|
\ '%A%f:%l: %m,' .
|
|
|
|
\ '%A%f:(%l): %m,' .
|
2013-05-10 07:11:07 -04:00
|
|
|
\ '%-Z%p^%.%#,' .
|
|
|
|
\ '%-G%.%#'
|
2013-01-20 06:07:05 -05:00
|
|
|
|
2013-05-10 07:11:07 -04:00
|
|
|
let loclist=SyntasticMake({
|
|
|
|
\ 'makeprg': makeprg,
|
|
|
|
\ 'errorformat': errorformat,
|
|
|
|
\ 'postprocess': ['sort'] })
|
2013-02-06 08:29:56 -05:00
|
|
|
|
2013-04-15 04:21:52 -04:00
|
|
|
for n in range(len(loclist))
|
2013-08-12 04:22:12 -04:00
|
|
|
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
|
2013-08-07 05:01:45 -04:00
|
|
|
let loclist[n]['vcol'] = 0
|
2013-04-15 04:21:52 -04:00
|
|
|
endfor
|
2013-01-20 07:27:19 -05:00
|
|
|
|
2013-05-10 07:11:07 -04:00
|
|
|
return loclist
|
2013-01-20 07:27:19 -05:00
|
|
|
endfunction
|
2013-01-23 19:01:30 -05:00
|
|
|
|
2013-08-07 05:01:45 -04:00
|
|
|
function s:PylintNew()
|
2013-09-19 18:16:36 -04:00
|
|
|
try
|
|
|
|
let pylint_version = filter(split(system('pylint --version'), '\m, \|\n'), 'v:val =~# "^pylint"')[0]
|
|
|
|
return syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(pylint_version), [1])
|
|
|
|
catch /E684/
|
|
|
|
return 0
|
|
|
|
endtry
|
2013-08-07 05:01:45 -04:00
|
|
|
endfunction
|
|
|
|
|
2013-01-23 19:01:30 -05:00
|
|
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
|
|
|
\ 'filetype': 'python',
|
2013-01-27 15:08:30 -05:00
|
|
|
\ 'name': 'pylint' })
|