add command to force a syntastic check

This allows a particular file type to be disabled but still be checked
when desired.  Useful for syntax checks that take a few seconds like the
puppet one.
This commit is contained in:
Nate Jones 2011-09-09 17:46:56 -07:00
parent cf6aa9a414
commit bb37d47018

View File

@ -52,12 +52,13 @@ if !exists("g:syntastic_stl_format")
endif endif
"refresh and redraw all the error info for this buf when saving or reading "refresh and redraw all the error info for this buf when saving or reading
autocmd bufreadpost,bufwritepost * call s:UpdateErrors() command SyntasticCheck call s:UpdateErrors(1)
function! s:UpdateErrors() autocmd bufreadpost,bufwritepost * call s:UpdateErrors(0)
function! s:UpdateErrors(skip_disabled)
if &buftype == 'quickfix' if &buftype == 'quickfix'
return return
endif endif
call s:CacheErrors() call s:CacheErrors(a:skip_disabled)
if g:syntastic_enable_balloons && has('balloon_eval') if g:syntastic_enable_balloons && has('balloon_eval')
let b:syntastic_balloons = {} let b:syntastic_balloons = {}
@ -95,12 +96,12 @@ endfunction
" "
"depends on a function called SyntaxCheckers_{&ft}_GetLocList() existing "depends on a function called SyntaxCheckers_{&ft}_GetLocList() existing
"elsewhere "elsewhere
function! s:CacheErrors() function! s:CacheErrors(skip_disabled)
let b:syntastic_loclist = [] let b:syntastic_loclist = []
if filereadable(expand("%")) if filereadable(expand("%"))
for ft in split(&ft, '\.') for ft in split(&ft, '\.')
if s:Checkable(ft) if s:Checkable(ft, a:skip_disabled)
let b:syntastic_loclist = extend(b:syntastic_loclist, SyntaxCheckers_{ft}_GetLocList()) let b:syntastic_loclist = extend(b:syntastic_loclist, SyntaxCheckers_{ft}_GetLocList())
endif endif
endfor endfor
@ -289,11 +290,15 @@ function! SyntasticMake(options)
return errors return errors
endfunction endfunction
function! s:Checkable(ft) function! s:Checkable(ft, skip_disabled)
if !exists("g:loaded_" . a:ft . "_syntax_checker") if !exists("g:loaded_" . a:ft . "_syntax_checker")
exec "runtime syntax_checkers/" . a:ft . ".vim" exec "runtime syntax_checkers/" . a:ft . ".vim"
endif endif
if a:skip_disabled
return 1
endif
return exists("*SyntaxCheckers_". a:ft ."_GetLocList") && return exists("*SyntaxCheckers_". a:ft ."_GetLocList") &&
\ index(g:syntastic_disabled_filetypes, a:ft) == -1 \ index(g:syntastic_disabled_filetypes, a:ft) == -1
endfunction endfunction
@ -310,7 +315,7 @@ function! s:Disable(...)
endif endif
"will cause existing errors to be cleared "will cause existing errors to be cleared
call s:UpdateErrors() call s:UpdateErrors(0)
endfunction endfunction
"enable syntax checking for the given filetype (defaulting to current ft) "enable syntax checking for the given filetype (defaulting to current ft)
@ -323,7 +328,7 @@ function! s:Enable(...)
endif endif
if !&modified if !&modified
call s:UpdateErrors() call s:UpdateErrors(0)
redraw! redraw!
else else
echom "Syntasic: enabled for the '" . ft . "' filetype. :write out to update errors" echom "Syntasic: enabled for the '" . ft . "' filetype. :write out to update errors"