syntastic/syntax_checkers/python/pep257.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

46 lines
1.4 KiB
VimL

"============================================================================
"File: pep257.vim
"Description: Docstring style checking plugin for syntastic.vim
"============================================================================
"
" For details about pep257 see: https://github.com/GreenSteam/pep257
if exists("g:loaded_syntastic_python_pep257_checker")
finish
endif
let g:loaded_syntastic_python_pep257_checker = 1
" sanity: kill empty lines here rather than munging errorformat
function! SyntaxCheckers_python_pep257_Preprocess(errors)
return filter(copy(a:errors), 'v:val != ""')
endfunction
function! SyntaxCheckers_python_pep257_GetLocList() dict
let makeprg = syntastic#makeprg#build({
\ 'exe': 'pep257',
\ 'checker': self })
let errorformat =
\ '%E%f:%l:%c%\%.%\%.%\d%\+:%\d%\+: %m,' .
\ '%E%f:%l:%c: %m,' .
\ '%+C %m'
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'subtype': 'Style',
\ 'preprocess': 'SyntaxCheckers_python_pep257_Preprocess',
\ 'postprocess': ['compressWhitespace'] })
" pep257 outputs byte offsets rather than column numbers
for n in range(len(loclist))
let loclist[n]['col'] = get(loclist[n], 'col', 0) + 1
endfor
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'python',
\ 'name': 'pep257'})