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
|
|
|
"============================================================================
|
2013-02-21 10:50:41 -05:00
|
|
|
if exists("g:loaded_syntastic_javascript_jslint_checker")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let g:loaded_syntastic_javascript_jslint_checker=1
|
|
|
|
|
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_HighlightTerm(error)
|
2013-10-25 08:46:16 -04:00
|
|
|
let unexpected = matchstr(a:error['text'], '\mExpected.*and instead saw \'\zs.*\ze\'')
|
2013-09-27 03:35:46 -04:00
|
|
|
if len(unexpected) < 1i
|
|
|
|
return ''
|
|
|
|
endif
|
2011-12-11 17:54:33 -05:00
|
|
|
return '\V'.split(unexpected, "'")[1]
|
|
|
|
endfunction
|
|
|
|
|
2013-10-28 07:53:33 -04:00
|
|
|
function! SyntaxCheckers_javascript_jslint_GetLocList() dict
|
2013-11-01 05:51:47 -04:00
|
|
|
let makeprg = self.makeprgBuild({ 'args': g:syntastic_javascript_jslint_conf })
|
2013-05-31 14:05:45 -04:00
|
|
|
|
2013-05-14 12:36:20 -04:00
|
|
|
let errorformat =
|
|
|
|
\ '%E %##%n %m,'.
|
|
|
|
\ '%-Z%.%#Line %l\, Pos %c,'.
|
|
|
|
\ '%-G%.%#'
|
2013-05-31 14:05:45 -04: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'})
|
|
|
|
|