2011-12-11 17:54:33 -05:00
|
|
|
"============================================================================
|
|
|
|
"File: jslint.vim
|
|
|
|
"Description: Javascript syntax checker - using jslint
|
|
|
|
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
|
|
|
"License: This program is free software. It comes without any warranty,
|
|
|
|
" to the extent permitted by applicable law. You can redistribute
|
|
|
|
" it and/or modify it under the terms of the Do What The Fuck You
|
|
|
|
" Want To Public License, Version 2, as published by Sam Hocevar.
|
|
|
|
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
2012-01-06 14:06:47 -05:00
|
|
|
"
|
|
|
|
"Tested with jslint 0.1.4.
|
2011-12-11 17:54:33 -05:00
|
|
|
"============================================================================
|
|
|
|
if !exists("g:syntastic_javascript_jslint_conf")
|
2012-01-06 14:06:47 -05:00
|
|
|
let g:syntastic_javascript_jslint_conf = "--white --undef --nomen --regexp --plusplus --bitwise --newcap --sloppy --vars"
|
2011-12-11 17:54:33 -05:00
|
|
|
endif
|
|
|
|
|
2013-01-27 15:08:30 -05:00
|
|
|
function! SyntaxCheckers_javascript_jslint_IsAvailable()
|
|
|
|
return executable('jslint')
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! SyntaxCheckers_javascript_jslint_HighlightTerm(error)
|
2011-12-11 17:54:33 -05:00
|
|
|
let unexpected = matchstr(a:error['text'], 'Expected.*and instead saw \'\zs.*\ze\'')
|
|
|
|
if len(unexpected) < 1 | return '' | end
|
|
|
|
return '\V'.split(unexpected, "'")[1]
|
|
|
|
endfunction
|
|
|
|
|
2013-01-27 15:08:30 -05:00
|
|
|
function! SyntaxCheckers_javascript_jslint_GetLocList()
|
2013-01-20 06:07:05 -05:00
|
|
|
let makeprg = syntastic#makeprg#build({
|
|
|
|
\ 'exe': 'jslint',
|
|
|
|
\ 'args': g:syntastic_javascript_jslint_conf,
|
|
|
|
\ 'subchecker': 'jslint' })
|
2011-12-23 18:09:03 -05:00
|
|
|
let errorformat='%E %##%n %m,%-Z%.%#Line %l\, Pos %c,%-G%.%#'
|
2012-03-02 05:05:15 -05:00
|
|
|
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr("")} })
|
2011-12-11 17:54:33 -05:00
|
|
|
endfunction
|
|
|
|
|
2013-01-27 15:08:30 -05:00
|
|
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
|
|
|
\ 'filetype': 'javascript',
|
|
|
|
\ 'name': 'jslint'})
|
|
|
|
|