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:
Martin Grenfell 2012-03-21 09:42:11 +00:00
parent abd55ed2a6
commit 3c569d2b97
5 changed files with 13 additions and 11 deletions

View File

@ -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

View File

@ -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')

View File

@ -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')

View File

@ -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')

View File

@ -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')