You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.9 KiB
VimL
98 lines
2.9 KiB
VimL
11 years ago
|
"============================================================================
|
||
|
"File: pylint.vim
|
||
|
"Description: Syntax checking plugin for syntastic.vim
|
||
|
"Author: Parantapa Bhattacharya <parantapa at gmail dot com>
|
||
|
"
|
||
|
"============================================================================
|
||
|
|
||
10 years ago
|
if exists('g:loaded_syntastic_python_pylint_checker')
|
||
11 years ago
|
finish
|
||
|
endif
|
||
|
let g:loaded_syntastic_python_pylint_checker = 1
|
||
|
|
||
10 years ago
|
if !exists('g:syntastic_python_pylint_sort')
|
||
|
let g:syntastic_python_pylint_sort = 1
|
||
|
endif
|
||
11 years ago
|
|
||
|
let s:save_cpo = &cpo
|
||
|
set cpo&vim
|
||
|
|
||
10 years ago
|
let s:pylint_new = -1
|
||
|
|
||
11 years ago
|
function! SyntaxCheckers_python_pylint_IsAvailable() dict
|
||
10 years ago
|
if !executable(self.getExec())
|
||
|
return 0
|
||
|
endif
|
||
|
|
||
|
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".
|
||
|
" On NixOS, that would be ".pylint-wrapped 0.26.0".
|
||
|
" On Arch Linux it's "pylint2 1.1.0".
|
||
|
" On new-ish Fedora it's "python3-pylint 1.2.0".
|
||
|
" Have you guys considered switching to creative writing yet? ;)
|
||
|
|
||
10 years ago
|
let pylint_version = filter( split(syntastic#util#system(self.getExecEscaped() . ' --version'), '\m, \=\|\n'),
|
||
10 years ago
|
\ 'v:val =~# ''\m^\(python[-0-9]*-\|\.\)\=pylint[-0-9]*\>''' )[0]
|
||
|
let ver = syntastic#util#parseVersion(substitute(pylint_version, '\v^\S+\s+', '', ''))
|
||
|
call self.setVersion(ver)
|
||
|
|
||
|
let s:pylint_new = syntastic#util#versionIsAtLeast(ver, [1])
|
||
|
catch /\m^Vim\%((\a\+)\)\=:E684/
|
||
|
call syntastic#log#error("checker python/pylint: can't parse version string (abnormal termination?)")
|
||
|
let s:pylint_new = -1
|
||
|
endtry
|
||
|
|
||
11 years ago
|
return s:pylint_new >= 0
|
||
|
endfunction
|
||
|
|
||
|
function! SyntaxCheckers_python_pylint_GetLocList() dict
|
||
|
let makeprg = self.makeprgBuild({
|
||
10 years ago
|
\ 'args_after': (s:pylint_new ?
|
||
|
\ '-f text --msg-template="{path}:{line}:{column}:{C}: [{symbol}] {msg}" -r n' :
|
||
|
\ '-f parseable -r n -i y') })
|
||
11 years ago
|
|
||
|
let errorformat =
|
||
|
\ '%A%f:%l:%c:%t: %m,' .
|
||
|
\ '%A%f:%l: %m,' .
|
||
|
\ '%A%f:(%l): %m,' .
|
||
|
\ '%-Z%p^%.%#,' .
|
||
|
\ '%-G%.%#'
|
||
|
|
||
10 years ago
|
let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
|
||
|
|
||
|
let loclist = SyntasticMake({
|
||
11 years ago
|
\ 'makeprg': makeprg,
|
||
|
\ 'errorformat': errorformat,
|
||
10 years ago
|
\ 'env': env,
|
||
11 years ago
|
\ 'returns': range(32) })
|
||
|
|
||
|
for e in loclist
|
||
|
if !s:pylint_new
|
||
|
let e['type'] = e['text'][1]
|
||
|
endif
|
||
|
|
||
|
if e['type'] =~? '\m^[EF]'
|
||
|
let e['type'] = 'E'
|
||
|
elseif e['type'] =~? '\m^[CRW]'
|
||
|
let e['type'] = 'W'
|
||
|
else
|
||
|
let e['valid'] = 0
|
||
|
endif
|
||
|
|
||
|
let e['col'] += 1
|
||
|
let e['vcol'] = 0
|
||
|
endfor
|
||
|
|
||
|
return loclist
|
||
|
endfunction
|
||
|
|
||
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||
|
\ 'filetype': 'python',
|
||
|
\ 'name': 'pylint' })
|
||
|
|
||
|
let &cpo = s:save_cpo
|
||
|
unlet s:save_cpo
|
||
|
|
||
10 years ago
|
" vim: set sw=4 sts=4 et fdm=marker:
|