pass a filetype to SyntasticLoadChecker
This is needed to handle compound filetypes since we cant imply the location of the syntax checker file from the filetype. e.g. we want to load `syntax_checkers/python/pylint.vim`, but the filetype is `python.django`. Previously this was causing `runtime syntax_checkers/python.django/pylint.vim` to be executed.
This commit is contained in:
parent
abd55ed2a6
commit
3c569d2b97
@ -466,8 +466,8 @@ endfunction
|
||||
|
||||
"load the chosen checker for the current filetype - useful for filetypes like
|
||||
"javascript that have more than one syntax checker
|
||||
function! s:LoadChecker(checker)
|
||||
exec "runtime syntax_checkers/" . &ft . "/" . a:checker . ".vim"
|
||||
function! s:LoadChecker(checker, ft)
|
||||
exec "runtime syntax_checkers/" . a:ft . "/" . a:checker . ".vim"
|
||||
endfunction
|
||||
|
||||
"return a string representing the state of buffer according to
|
||||
@ -602,22 +602,24 @@ endfunction
|
||||
"well as the names of the actual syntax checker executables. The checkers
|
||||
"should be listed in order of default preference.
|
||||
"
|
||||
"if a option called 'g:syntastic_[filetype]_checker' exists then attempt to
|
||||
"a:ft should be the filetype for the checkers being loaded
|
||||
"
|
||||
"if a option called 'g:syntastic_{a:ft}_checker' exists then attempt to
|
||||
"load the checker that it points to
|
||||
function! SyntasticLoadChecker(checkers)
|
||||
let opt_name = "g:syntastic_" . &ft . "_checker"
|
||||
function! SyntasticLoadChecker(checkers, ft)
|
||||
let opt_name = "g:syntastic_" . a:ft . "_checker"
|
||||
|
||||
if exists(opt_name)
|
||||
let opt_val = {opt_name}
|
||||
if index(a:checkers, opt_val) != -1 && executable(opt_val)
|
||||
call s:LoadChecker(opt_val)
|
||||
call s:LoadChecker(opt_val, a:ft)
|
||||
else
|
||||
echoerr &ft . " syntax not supported or not installed."
|
||||
endif
|
||||
else
|
||||
for checker in a:checkers
|
||||
if executable(checker)
|
||||
return s:LoadChecker(checker)
|
||||
return s:LoadChecker(checker, a:ft)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
@ -19,4 +19,4 @@ endif
|
||||
let loaded_go_syntax_checker = 1
|
||||
|
||||
let s:supported_checkers = ["6g", "gofmt"]
|
||||
call SyntasticLoadChecker(s:supported_checkers)
|
||||
call SyntasticLoadChecker(s:supported_checkers, 'go')
|
||||
|
@ -20,4 +20,4 @@ endif
|
||||
let loaded_javascript_syntax_checker = 1
|
||||
|
||||
let s:supported_checkers = ["gjslint", "jslint", "jsl", "jshint"]
|
||||
call SyntasticLoadChecker(s:supported_checkers)
|
||||
call SyntasticLoadChecker(s:supported_checkers, 'javascript')
|
||||
|
@ -20,4 +20,4 @@ endif
|
||||
let loaded_json_syntax_checker = 1
|
||||
|
||||
let s:supported_checkers = ["jsonlint", "jsonval"]
|
||||
call SyntasticLoadChecker(s:supported_checkers)
|
||||
call SyntasticLoadChecker(s:supported_checkers, 'json')
|
||||
|
@ -24,4 +24,4 @@ if !exists('g:syntastic_python_checker_args')
|
||||
endif
|
||||
|
||||
let s:supported_checkers = ["flake8", "pyflakes", "pylint"]
|
||||
call SyntasticLoadChecker(s:supported_checkers)
|
||||
call SyntasticLoadChecker(s:supported_checkers, 'python')
|
||||
|
Loading…
Reference in New Issue
Block a user