syntastic/syntax_checkers/sh/shellcheck.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.5 KiB
VimL

"============================================================================
"File: shellcheck.vim
"Description: Shell script syntax/style checking plugin for syntastic.vim
"============================================================================
if exists("g:loaded_syntastic_sh_shellcheck_checker")
finish
endif
let g:loaded_syntastic_sh_shellcheck_checker = 1
function! SyntaxCheckers_sh_shellcheck_Preprocess(json)
" A hat tip to Mark Weber for this trick
" http://stackoverflow.com/a/19105763
let errors = eval(join(a:json, ''))
call filter(errors, 'v:val["level"] =~? ''\v^(error|warning|style)$''')
return map(errors, 'v:val["level"][0] . ":" . v:val["line"] . ":" . v:val["column"] . ":" . v:val["message"]')
endfunction
function! SyntaxCheckers_sh_shellcheck_GetLocList()
let makeprg = expand(self.getExec()) . ' < ' . syntastic#util#shexpand('%')
let errorformat = '%t:%l:%v:%m'
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'preprocess': 'SyntaxCheckers_sh_shellcheck_Preprocess',
\ 'defaults': {'bufnr': bufnr("")},
\ 'returns': [0] })
for e in loclist
if e['type'] ==? 's'
let e['type'] = 'w'
let e['subtype'] = 'Style'
endif
endfor
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'sh',
\ 'name': 'shellcheck',
\ 'exec': 'jsoncheck' })