mirror of
https://github.com/amix/vimrc
synced 2025-06-24 07:44:59 +08:00
Use syntastic instead of pyflakes (supports a ton of more languages)
This commit is contained in:
@ -0,0 +1,76 @@
|
||||
"============================================================================
|
||||
"File: closurecompiler.vim
|
||||
"Description: Javascript syntax checker - using Google Closure Compiler
|
||||
"Maintainer: Motohiro Takayama <mootoh 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.
|
||||
"============================================================================
|
||||
"
|
||||
" To enable this plugin, edit the .vimrc like this:
|
||||
"
|
||||
" let g:syntastic_javascript_checker = "closurecompiler"
|
||||
"
|
||||
" and set the path to the Google Closure Compiler:
|
||||
"
|
||||
" let g:syntastic_javascript_closure_compiler_path = '/path/to/google-closure-compiler.jar'
|
||||
"
|
||||
" It takes additional options for Google Closure Compiler with the variable
|
||||
" g:syntastic_javascript_closure_compiler_options.
|
||||
"
|
||||
|
||||
if exists("g:loaded_syntastic_javascript_closurecompiler_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_javascript_closurecompiler_checker = 1
|
||||
|
||||
if !exists("g:syntastic_javascript_closure_compiler_options")
|
||||
let g:syntastic_javascript_closure_compiler_options = ""
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_javascript_closurecompiler_IsAvailable() dict
|
||||
return
|
||||
\ executable("java") &&
|
||||
\ exists("g:syntastic_javascript_closure_compiler_path") &&
|
||||
\ filereadable(g:syntastic_javascript_closure_compiler_path)
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_javascript_closurecompiler_GetLocList() dict
|
||||
if exists("g:syntastic_javascript_closure_compiler_file_list")
|
||||
let file_list = join(readfile(g:syntastic_javascript_closure_compiler_file_list))
|
||||
else
|
||||
let file_list = syntastic#util#shexpand('%')
|
||||
endif
|
||||
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'exe': 'java -jar ' . g:syntastic_javascript_closure_compiler_path,
|
||||
\ 'args': g:syntastic_javascript_closure_compiler_options,
|
||||
\ 'args_after': '--js' ,
|
||||
\ 'fname': file_list })
|
||||
|
||||
let errorformat =
|
||||
\ '%-GOK,'.
|
||||
\ '%E%f:%l: ERROR - %m,'.
|
||||
\ '%Z%p^,'.
|
||||
\ '%W%f:%l: WARNING - %m,'.
|
||||
\ '%Z%p^'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'javascript',
|
||||
\ 'name': 'closurecompiler',
|
||||
\ 'exec': 'java'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
@ -0,0 +1,50 @@
|
||||
"============================================================================
|
||||
"File: eslint.vim
|
||||
"Description: Javascript syntax checker - using eslint
|
||||
"Maintainer: Maksim Ryzhikov <rv.maksim 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.
|
||||
"============================================================================
|
||||
|
||||
if exists('g:loaded_syntastic_javascript_eslint_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_javascript_eslint_checker = 1
|
||||
|
||||
if !exists('g:syntastic_javascript_eslint_conf')
|
||||
let g:syntastic_javascript_eslint_conf = ''
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_javascript_eslint_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'args': (g:syntastic_javascript_eslint_conf != '' ? '--config ' . g:syntastic_javascript_eslint_conf : '') })
|
||||
|
||||
let errorformat =
|
||||
\ '%E%f: line %l\, col %c\, Error - %m'
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'postprocess': ['sort'] })
|
||||
|
||||
for e in loclist
|
||||
let e['col'] += 1
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'javascript',
|
||||
\ 'name': 'eslint'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
@ -0,0 +1,48 @@
|
||||
"============================================================================
|
||||
"File: gjslint.vim
|
||||
"Description: Javascript syntax checker - using gjslint
|
||||
"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.
|
||||
"============================================================================
|
||||
|
||||
if exists("g:loaded_syntastic_javascript_gjslint_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_javascript_gjslint_checker = 1
|
||||
|
||||
if !exists("g:syntastic_javascript_gjslint_conf")
|
||||
let g:syntastic_javascript_gjslint_conf = ""
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_javascript_gjslint_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'args': g:syntastic_javascript_gjslint_conf,
|
||||
\ 'args_after': '--nosummary --unix_mode --nodebug_indentation --nobeep' })
|
||||
|
||||
let errorformat =
|
||||
\ "%f:%l:(New Error -%\\?\%n) %m," .
|
||||
\ "%f:%l:(-%\\?%n) %m," .
|
||||
\ "%-G1 files checked," .
|
||||
\ " no errors found.," .
|
||||
\ "%-G%.%#"
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'javascript',
|
||||
\ 'name': 'gjslint'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
@ -0,0 +1,42 @@
|
||||
"============================================================================
|
||||
"File: jscs.vim
|
||||
"Description: Javascript syntax checker - using jscs
|
||||
"Maintainer: LCD 47 <lcd047@gmail.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.
|
||||
"============================================================================
|
||||
|
||||
if exists("g:loaded_syntastic_javascript_jscs_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_javascript_jscs_checker = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" we borrow SyntaxCheckers_java_checkstyle_Preprocess() from java/checkstyle
|
||||
runtime! syntax_checkers/java/*.vim
|
||||
|
||||
function! SyntaxCheckers_javascript_jscs_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({ 'args_after': '--no-colors --reporter checkstyle' })
|
||||
let errorformat = '%f:%t:%l:%c:%m'
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'subtype': 'Style',
|
||||
\ 'preprocess': 'SyntaxCheckers_java_checkstyle_Preprocess',
|
||||
\ 'postprocess': ['sort'],
|
||||
\ 'returns': [0] })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'javascript',
|
||||
\ 'name': 'jscs'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
@ -0,0 +1,60 @@
|
||||
"============================================================================
|
||||
"File: jshint.vim
|
||||
"Description: Javascript syntax checker - using jshint
|
||||
"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.
|
||||
"============================================================================
|
||||
|
||||
if exists('g:loaded_syntastic_javascript_jshint_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_javascript_jshint_checker = 1
|
||||
|
||||
if !exists('g:syntastic_jshint_exec')
|
||||
let g:syntastic_jshint_exec = 'jshint'
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_javascript_jshint_conf')
|
||||
let g:syntastic_javascript_jshint_conf = ''
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_javascript_jshint_IsAvailable() dict
|
||||
return executable(expand(g:syntastic_jshint_exec))
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_javascript_jshint_GetLocList() dict
|
||||
if !exists('s:jshint_new')
|
||||
let s:jshint_new =
|
||||
\ syntastic#util#versionIsAtLeast(syntastic#util#getVersion(expand(g:syntastic_jshint_exec) . ' --version'), [1, 1])
|
||||
endif
|
||||
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'exe': expand(g:syntastic_jshint_exec),
|
||||
\ 'args': (g:syntastic_javascript_jshint_conf != '' ? '--config ' . g:syntastic_javascript_jshint_conf : ''),
|
||||
\ 'args_after': (s:jshint_new ? '--verbose ' : '') })
|
||||
|
||||
let errorformat = s:jshint_new ?
|
||||
\ '%A%f: line %l\, col %v\, %m \(%t%*\d\)' :
|
||||
\ '%E%f: line %l\, col %v\, %m'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr('')} })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'javascript',
|
||||
\ 'name': 'jshint'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
@ -0,0 +1,50 @@
|
||||
"============================================================================
|
||||
"File: jsl.vim
|
||||
"Description: Javascript syntax checker - using jsl
|
||||
"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.
|
||||
"============================================================================
|
||||
|
||||
if exists("g:loaded_syntastic_javascript_jsl_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_javascript_jsl_checker = 1
|
||||
|
||||
if !exists("g:syntastic_javascript_jsl_conf")
|
||||
let g:syntastic_javascript_jsl_conf = ""
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_javascript_jsl_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'args': (g:syntastic_javascript_jsl_conf != '' ? '-conf ' . g:syntastic_javascript_jsl_conf : ''),
|
||||
\ 'args_after': '-nologo -nofilelisting -nosummary -nocontext -process' })
|
||||
|
||||
let errorformat =
|
||||
\ '%W%f(%l): lint warning: %m,'.
|
||||
\ '%-Z%p^,'.
|
||||
\ '%W%f(%l): warning: %m,'.
|
||||
\ '%-Z%p^,'.
|
||||
\ '%E%f(%l): SyntaxError: %m,'.
|
||||
\ '%-Z%p^,'.
|
||||
\ '%-G'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'javascript',
|
||||
\ 'name': 'jsl'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
@ -0,0 +1,51 @@
|
||||
"============================================================================
|
||||
"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.
|
||||
"
|
||||
"Tested with jslint 0.1.4.
|
||||
"============================================================================
|
||||
if exists("g:loaded_syntastic_javascript_jslint_checker")
|
||||
finish
|
||||
endif
|
||||
|
||||
let g:loaded_syntastic_javascript_jslint_checker = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_javascript_jslint_GetHighlightRegex(item)
|
||||
let term = matchstr(a:item['text'], '\mExpected .* and instead saw ''\zs.*\ze''')
|
||||
if term != ''
|
||||
let term = '\V' . term
|
||||
endif
|
||||
return term
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_javascript_jslint_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({ 'args': '--white --nomen --regexp --plusplus --bitwise --newcap --sloppy --vars' })
|
||||
|
||||
let errorformat =
|
||||
\ '%E %##%\d%\+ %m,'.
|
||||
\ '%-Z%.%#Line %l\, Pos %c,'.
|
||||
\ '%-G%.%#'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")} })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'javascript',
|
||||
\ 'name': 'jslint'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
Reference in New Issue
Block a user