@ -9,7 +9,7 @@
"
"
"============================================================================
"============================================================================
if exists ( "g:loaded_syntastic_plugin" )
if exists ( 'g:loaded_syntastic_plugin' )
finish
finish
endif
endif
let g :loaded_syntastic_plugin = 1
let g :loaded_syntastic_plugin = 1
@ -19,7 +19,7 @@ if has('reltime')
lockvar ! g :_SYNTASTIC_START
lockvar ! g :_SYNTASTIC_START
endif
endif
let g :_SYNTASTIC_VERSION = '3.6.0- 5 '
let g :_SYNTASTIC_VERSION = '3.6.0- 102 '
lockvar g :_SYNTASTIC_VERSION
lockvar g :_SYNTASTIC_VERSION
" Sanity checks {{{1
" Sanity checks {{{1
@ -34,7 +34,7 @@ for s:feature in [
\ 'user_commands'
\ 'user_commands'
\ ]
\ ]
if ! has ( s :feature )
if ! has ( s :feature )
call syntastic #log #error ( "need Vim compiled with feature " . s :feature )
call syntastic #log #error ( 'need Vim compiled with feature ' . s :feature )
finish
finish
endif
endif
endfor
endfor
@ -42,15 +42,25 @@ endfor
let s :_running_windows = syntastic #util #isRunningWindows ( )
let s :_running_windows = syntastic #util #isRunningWindows ( )
lockvar s :_running_windows
lockvar s :_running_windows
if ! s :_running_windows && executable ( 'uname' )
if ! exists ( 'g:syntastic_shell' )
let g :syntastic_shell = &shell
endif
if s :_running_windows
let g :_SYNTASTIC_UNAME = 'Windows'
elseif executable ( 'uname' )
try
try
let s :_uname = system ( 'uname' )
let g:_SYNTASTIC_UNAME = split ( syntastic #util #system ( 'uname' ) , "\n" ) [0 ]
catch /\m^Vim\%((\a\+)\)\=:E484/
catch /\m^Vim\%((\a\+)\)\=:E484/
call syntastic #log #error ( "your shell " . &shell . " can't handle traditional UNIX syntax for redirections" )
call syntastic #log #error ( "your shell " . syntastic #util #var ( 'shell' ) . " can't handle traditional UNIX syntax for redirections" )
finish
finish
catch /\m^Vim\%((\a\+)\)\=:E684/
let g :_SYNTASTIC_UNAME = 'Unknown'
endtry
endtry
lockvar s :_uname
else
let g :_SYNTASTIC_UNAME = 'Unknown'
endif
endif
lockvar g :_SYNTASTIC_UNAME
" }}}1
" }}}1
@ -61,7 +71,6 @@ let g:_SYNTASTIC_DEFAULTS = {
\ 'always_populate_loc_list' : 0 ,
\ 'always_populate_loc_list' : 0 ,
\ 'auto_jump' : 0 ,
\ 'auto_jump' : 0 ,
\ 'auto_loc_list' : 2 ,
\ 'auto_loc_list' : 2 ,
\ 'bash_hack' : 0 ,
\ 'check_on_open' : 0 ,
\ 'check_on_open' : 0 ,
\ 'check_on_wq' : 1 ,
\ 'check_on_wq' : 1 ,
\ 'cursor_columns' : 1 ,
\ 'cursor_columns' : 1 ,
@ -71,7 +80,7 @@ let g:_SYNTASTIC_DEFAULTS = {
\ 'enable_highlighting' : 1 ,
\ 'enable_highlighting' : 1 ,
\ 'enable_signs' : 1 ,
\ 'enable_signs' : 1 ,
\ 'error_symbol' : '>>' ,
\ 'error_symbol' : '>>' ,
\ 'exit_checks' : ! ( s :_running_windows && &shell = ~ ? '\m\<cmd\.exe$' ) ,
\ 'exit_checks' : ! ( s :_running_windows && syntastic #util #var ( 'shell' , &shell ) = ~ ? '\m\<cmd\.exe$' ) ,
\ 'filetype_map' : {},
\ 'filetype_map' : {},
\ 'full_redraws' : ! ( has ( 'gui_running' ) | | has ( 'gui_macvim' ) ) ,
\ 'full_redraws' : ! ( has ( 'gui_running' ) | | has ( 'gui_macvim' ) ) ,
\ 'id_checkers' : 1 ,
\ 'id_checkers' : 1 ,
@ -80,6 +89,7 @@ let g:_SYNTASTIC_DEFAULTS = {
\ 'loc_list_height' : 10 ,
\ 'loc_list_height' : 10 ,
\ 'quiet_messages' : {},
\ 'quiet_messages' : {},
\ 'reuse_loc_lists' : 0 ,
\ 'reuse_loc_lists' : 0 ,
\ 'shell' : &shell ,
\ 'sort_aggregated_errors' : 1 ,
\ 'sort_aggregated_errors' : 1 ,
\ 'stl_format' : '[Syntax: line:%F (%t)]' ,
\ 'stl_format' : '[Syntax: line:%F (%t)]' ,
\ 'style_error_symbol' : 'S>' ,
\ 'style_error_symbol' : 'S>' ,
@ -94,7 +104,7 @@ for s:key in keys(g:_SYNTASTIC_DEFAULTS)
endif
endif
endfor
endfor
if exists ( "g:syntastic_quiet_warnings" )
if exists ( 'g:syntastic_quiet_warnings' )
call syntastic #log #oneTimeWarn ( "variable g:syntastic_quiet_warnings is deprecated, please use let g:syntastic_quiet_messages = {'level': 'warnings'} instead" )
call syntastic #log #oneTimeWarn ( "variable g:syntastic_quiet_warnings is deprecated, please use let g:syntastic_quiet_messages = {'level': 'warnings'} instead" )
if g :syntastic_quiet_warnings
if g :syntastic_quiet_warnings
let s :quiet_warnings = get ( g :syntastic_quiet_messages , 'type' , [])
let s :quiet_warnings = get ( g :syntastic_quiet_messages , 'type' , [])
@ -152,7 +162,7 @@ let s:modemap = g:SyntasticModeMap.Instance()
" @vimlint(EVL103, 1, a:cursorPos)
" @vimlint(EVL103, 1, a:cursorPos)
" @vimlint(EVL103, 1, a:cmdLine)
" @vimlint(EVL103, 1, a:cmdLine)
" @vimlint(EVL103, 1, a:argLead)
" @vimlint(EVL103, 1, a:argLead)
function ! s :CompleteCheckerName ( argLead , cmdLine , cursorPos ) " {{{2
function ! s :CompleteCheckerName ( argLead , cmdLine , cursorPos ) abort " {{{2
let checker_names = []
let checker_names = []
for ft in s :_resolve_filetypes ( [])
for ft in s :_resolve_filetypes ( [])
call extend ( checker_names , s :registry .getNamesOfAvailableCheckers ( ft ) )
call extend ( checker_names , s :registry .getNamesOfAvailableCheckers ( ft ) )
@ -167,7 +177,7 @@ endfunction " }}}2
" @vimlint(EVL103, 1, a:cursorPos)
" @vimlint(EVL103, 1, a:cursorPos)
" @vimlint(EVL103, 1, a:cmdLine)
" @vimlint(EVL103, 1, a:cmdLine)
" @vimlint(EVL103, 1, a:argLead)
" @vimlint(EVL103, 1, a:argLead)
function ! s :CompleteFiletypes ( argLead , cmdLine , cursorPos ) " {{{2
function ! s :CompleteFiletypes ( argLead , cmdLine , cursorPos ) abort " {{{2
return join ( s :registry .getKnownFiletypes ( ) , "\n" )
return join ( s :registry .getKnownFiletypes ( ) , "\n" )
endfunction " }}}2
endfunction " }}}2
" @vimlint(EVL103, 0, a:cursorPos)
" @vimlint(EVL103, 0, a:cursorPos)
@ -185,34 +195,34 @@ command! SyntasticSetLoclist call SyntasticSetLoclist()
" Public API {{{1
" Public API {{{1
function ! SyntasticCheck ( ...) " {{{2
function ! SyntasticCheck ( ...) abort " {{{2
call s :UpdateErrors ( 0 , a :000 )
call s :UpdateErrors ( 0 , a :000 )
call syntastic #util #redraw ( g :syntastic_full_redraws )
call syntastic #util #redraw ( g :syntastic_full_redraws )
endfunction " }}}2
endfunction " }}}2
function ! SyntasticInfo ( ...) " {{{2
function ! SyntasticInfo ( ...) abort " {{{2
call s :modemap .modeInfo ( a :000 )
call s :modemap .modeInfo ( a :000 )
call s :registry .echoInfoFor ( s :_resolve_filetypes ( a :000 ) )
call s :registry .echoInfoFor ( s :_resolve_filetypes ( a :000 ) )
call s :_explain_skip ( a :000 )
call s :_explain_skip ( a :000 )
endfunction " }}}2
endfunction " }}}2
function ! SyntasticErrors ( ) " {{{2
function ! SyntasticErrors ( ) abort " {{{2
call g :SyntasticLoclist .current ( ) .show ( )
call g :SyntasticLoclist .current ( ) .show ( )
endfunction " }}}2
endfunction " }}}2
function ! SyntasticReset ( ) " {{{2
function ! SyntasticReset ( ) abort " {{{2
call s :ClearCache ( )
call s :ClearCache ( )
call s :notifiers .refresh ( g :SyntasticLoclist .New ( []) )
call s :notifiers .refresh ( g :SyntasticLoclist .New ( []) )
endfunction " }}}2
endfunction " }}}2
function ! SyntasticToggleMode ( ) " {{{2
function ! SyntasticToggleMode ( ) abort " {{{2
call s :modemap .toggleMode ( )
call s :modemap .toggleMode ( )
call s :ClearCache ( )
call s :ClearCache ( )
call s :notifiers .refresh ( g :SyntasticLoclist .New ( []) )
call s :notifiers .refresh ( g :SyntasticLoclist .New ( []) )
call s :modemap .echoMode ( )
call s :modemap .echoMode ( )
endfunction " }}}2
endfunction " }}}2
function ! SyntasticSetLoclist ( ) " {{{2
function ! SyntasticSetLoclist ( ) abort " {{{2
call g :SyntasticLoclist .current ( ) .setloclist ( )
call g :SyntasticLoclist .current ( ) .setloclist ( )
endfunction " }}}2
endfunction " }}}2
@ -233,32 +243,32 @@ if v:version > 703 || (v:version == 703 && has('patch544'))
augroup END
augroup END
endif
endif
function ! s :BufReadPostHook ( ) " {{{2
function ! s :BufReadPostHook ( ) abort " {{{2
if g :syntastic_check_on_open
if g :syntastic_check_on_open
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_AUTOCOMMANDS ,
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_AUTOCOMMANDS ,
\ 'autocmd: BufReadPost, buffer ' . bufnr ( "" ) . ' = ' . string ( bufname ( str2nr ( bufnr ( "" ) ) ) ) )
\ 'autocmd: BufReadPost, buffer ' . bufnr ( '' ) . ' = ' . string ( bufname ( str2nr ( bufnr ( '' ) ) ) ) )
call s :UpdateErrors ( 1 , [])
call s :UpdateErrors ( 1 , [])
endif
endif
endfunction " }}}2
endfunction " }}}2
function ! s :BufWritePostHook ( ) " {{{2
function ! s :BufWritePostHook ( ) abort " {{{2
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_AUTOCOMMANDS ,
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_AUTOCOMMANDS ,
\ 'autocmd: BufWritePost, buffer ' . bufnr ( "" ) . ' = ' . string ( bufname ( str2nr ( bufnr ( "" ) ) ) ) )
\ 'autocmd: BufWritePost, buffer ' . bufnr ( '' ) . ' = ' . string ( bufname ( str2nr ( bufnr ( '' ) ) ) ) )
call s :UpdateErrors ( 1 , [])
call s :UpdateErrors ( 1 , [])
endfunction " }}}2
endfunction " }}}2
function ! s :BufEnterHook ( ) " {{{2
function ! s :BufEnterHook ( ) abort " {{{2
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_AUTOCOMMANDS ,
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_AUTOCOMMANDS ,
\ 'autocmd: BufEnter, buffer ' . bufnr ( "" ) . ' = ' . string ( bufname ( str2nr ( bufnr ( "" ) ) ) ) .
\ 'autocmd: BufEnter, buffer ' . bufnr ( '' ) . ' = ' . string ( bufname ( str2nr ( bufnr ( '' ) ) ) ) .
\ ', &buftype = ' . string ( &buftype ) )
\ ', &buftype = ' . string ( &buftype ) )
if &buftype = = ''
if &buftype = = # ''
call s :notifiers .refresh ( g :SyntasticLoclist .current ( ) )
call s :notifiers .refresh ( g :SyntasticLoclist .current ( ) )
elseif &buftype = = 'quickfix'
elseif &buftype = = # 'quickfix'
" TODO: this is needed because in recent versions of Vim lclose
" TODO: this is needed because in recent versions of Vim lclose
" can no longer be called from BufWinLeave
" can no longer be called from BufWinLeave
" TODO: at this point there is no b:syntastic_loclist
" TODO: at this point there is no b:syntastic_loclist
let loclist = filter ( copy ( getloclist ( 0 ) ) , 'v:val["valid"] == 1' )
let loclist = filter ( copy ( getloclist ( 0 ) ) , 'v:val["valid"] == 1' )
let owner = str2nr ( getbufvar ( bufnr ( "" ) , 'syntastic_owner_buffer' ) )
let owner = str2nr ( getbufvar ( bufnr ( '' ) , 'syntastic_owner_buffer' ) )
let buffers = syntastic #util #unique ( map ( loclist , 'v:val["bufnr"]' ) + ( owner ? [owner ] : []) )
let buffers = syntastic #util #unique ( map ( loclist , 'v:val["bufnr"]' ) + ( owner ? [owner ] : []) )
if get ( w :, 'syntastic_loclist_set' , 0 ) && ! empty ( loclist ) && empty ( filter ( buffers , 'syntastic#util#bufIsActive(v:val)' ) )
if get ( w :, 'syntastic_loclist_set' , 0 ) && ! empty ( loclist ) && empty ( filter ( buffers , 'syntastic#util#bufIsActive(v:val)' ) )
call SyntasticLoclistHide ( )
call SyntasticLoclistHide ( )
@ -266,9 +276,9 @@ function! s:BufEnterHook() " {{{2
endif
endif
endfunction " }}}2
endfunction " }}}2
function ! s :QuitPreHook ( ) " {{{2
function ! s :QuitPreHook ( ) abort " {{{2
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_AUTOCOMMANDS ,
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_AUTOCOMMANDS ,
\ 'autocmd: QuitPre, buffer ' . bufnr ( "" ) . ' = ' . string ( bufname ( str2nr ( bufnr ( "" ) ) ) ) )
\ 'autocmd: QuitPre, buffer ' . bufnr ( '' ) . ' = ' . string ( bufname ( str2nr ( bufnr ( '' ) ) ) ) )
let b :syntastic_skip_checks = get ( b :, 'syntastic_skip_checks' , 0 ) | | ! syntastic #util #var ( 'check_on_wq' )
let b :syntastic_skip_checks = get ( b :, 'syntastic_skip_checks' , 0 ) | | ! syntastic #util #var ( 'check_on_wq' )
if get ( w :, 'syntastic_loclist_set' , 0 )
if get ( w :, 'syntastic_loclist_set' , 0 )
call SyntasticLoclistHide ( )
call SyntasticLoclistHide ( )
@ -280,7 +290,7 @@ endfunction " }}}2
" Main {{{1
" Main {{{1
"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
function ! s :UpdateErrors ( auto_invoked , checker_names ) " {{{2
function ! s :UpdateErrors ( auto_invoked , checker_names ) abort " {{{2
call syntastic #log #debugShowVariables ( g :_SYNTASTIC_DEBUG_TRACE , 'version' )
call syntastic #log #debugShowVariables ( g :_SYNTASTIC_DEBUG_TRACE , 'version' )
call syntastic #log #debugShowOptions ( g :_SYNTASTIC_DEBUG_TRACE , s :_DEBUG_DUMP_OPTIONS )
call syntastic #log #debugShowOptions ( g :_SYNTASTIC_DEBUG_TRACE , s :_DEBUG_DUMP_OPTIONS )
call syntastic #log #debugDump ( g :_SYNTASTIC_DEBUG_VARIABLES )
call syntastic #log #debugDump ( g :_SYNTASTIC_DEBUG_VARIABLES )
@ -294,6 +304,9 @@ function! s:UpdateErrors(auto_invoked, checker_names) " {{{2
let run_checks = ! a :auto_invoked | | s :modemap .doAutoChecking ( )
let run_checks = ! a :auto_invoked | | s :modemap .doAutoChecking ( )
if run_checks
if run_checks
call s :CacheErrors ( a :checker_names )
call s :CacheErrors ( a :checker_names )
unlockvar ! b :syntastic_changedtick
let b :syntastic_changedtick = b :changedtick
lockvar ! b :syntastic_changedtick
endif
endif
let loclist = g :SyntasticLoclist .current ( )
let loclist = g :SyntasticLoclist .current ( )
@ -325,7 +338,7 @@ function! s:UpdateErrors(auto_invoked, checker_names) " {{{2
" order, which can lead to missing filetype when jumping
" order, which can lead to missing filetype when jumping
" to a new file; the following is a workaround for the
" to a new file; the following is a workaround for the
" resulting brain damage
" resulting brain damage
if &filetype = = ''
if &filetype = = # ''
silent ! filetype detect
silent ! filetype detect
endif
endif
endif
endif
@ -336,13 +349,13 @@ function! s:UpdateErrors(auto_invoked, checker_names) " {{{2
endfunction " }}}2
endfunction " }}}2
"clear the loc list for the buffer
"clear the loc list for the buffer
function ! s :ClearCache ( ) " {{{2
function ! s :ClearCache ( ) abort " {{{2
call s :notifiers .reset ( g :SyntasticLoclist .current ( ) )
call s :notifiers .reset ( g :SyntasticLoclist .current ( ) )
call b :syntastic_loclist .destroy ( )
call b :syntastic_loclist .destroy ( )
endfunction " }}}2
endfunction " }}}2
"detect and cache all syntax errors in this buffer
"detect and cache all syntax errors in this buffer
function ! s :CacheErrors ( checker_names ) " {{{2
function ! s :CacheErrors ( checker_names ) abort " {{{2
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_TRACE , 'CacheErrors: ' .
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_TRACE , 'CacheErrors: ' .
\ ( len ( a :checker_names ) ? join ( a :checker_names ) : 'default checkers' ) )
\ ( len ( a :checker_names ) ? join ( a :checker_names ) : 'default checkers' ) )
call s :ClearCache ( )
call s :ClearCache ( )
@ -351,7 +364,8 @@ function! s:CacheErrors(checker_names) " {{{2
if ! s :_skip_file ( )
if ! s :_skip_file ( )
" debug logging {{{3
" debug logging {{{3
call syntastic #log #debugShowVariables ( g :_SYNTASTIC_DEBUG_TRACE , 'aggregate_errors' )
call syntastic #log #debugShowVariables ( g :_SYNTASTIC_DEBUG_TRACE , 'aggregate_errors' )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_TRACE , 'getcwd() = ' . getcwd ( ) )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_CHECKERS , '$PATH = ' . string ( $PATH ) )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_TRACE , 'getcwd() = ' . string ( getcwd ( ) ) )
" }}}3
" }}}3
let filetypes = s :_resolve_filetypes ( [])
let filetypes = s :_resolve_filetypes ( [])
@ -452,20 +466,15 @@ endfunction " }}}2
" 'env' - environment variables to set before running the checker
" 'env' - environment variables to set before running the checker
" 'returns' - a list of valid exit codes for the checker
" 'returns' - a list of valid exit codes for the checker
" @vimlint(EVL102, 1, l:env_save)
" @vimlint(EVL102, 1, l:env_save)
function ! SyntasticMake ( options ) " {{{2
function ! SyntasticMake ( options ) abort " {{{2
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_TRACE , 'SyntasticMake: called with options:' , a :options )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_TRACE , 'SyntasticMake: called with options:' , a :options )
" save options and locale env variables {{{3
" save options and locale env variables {{{3
let old_shellredir = &shellredir
let old_local_errorformat = &l :errorformat
let old_local_errorformat = &l :errorformat
let old_errorformat = &errorformat
let old_errorformat = &errorformat
let old_cwd = getcwd ( )
let old_cwd = getcwd ( )
let old_lc_messages = $LC_MESSAGES
let old_lc_all = $LC_ALL
" }}}3
" }}}3
call s :_bash_hack ( )
if has_key ( a :options , 'errorformat' )
if has_key ( a :options , 'errorformat' )
let &errorformat = a :options ['errorformat' ]
let &errorformat = a :options ['errorformat' ]
endif
endif
@ -479,23 +488,19 @@ function! SyntasticMake(options) " {{{2
if has_key ( a :options , 'env' ) && len ( a :options ['env' ])
if has_key ( a :options , 'env' ) && len ( a :options ['env' ])
for key in keys ( a :options ['env' ])
for key in keys ( a :options ['env' ])
if key = ~ ? '\m^[a-z_]\+$'
if key = ~ ? '\m^[a-z_]\+$'
exec 'let env_save[' . string ( key ) . '] = $' . key
exec ute 'let env_save[' . string ( key ) . '] = $' . key
exec 'let $' . key . ' = ' . string ( a :options ['env' ][key ])
exec ute 'let $' . key . ' = ' . string ( a :options ['env' ][key ])
endif
endif
endfor
endfor
endif
endif
let $LC_MESSAGES = 'C'
let $LC_ALL = ''
" }}}3
" }}}3
let err_lines = split ( sy stem( a :options ['makeprg' ]) , "\n" , 1 )
let err_lines = split ( sy ntastic#util #sy stem( a :options ['makeprg' ]) , "\n" , 1 )
" restore environment variables {{{3
" restore environment variables {{{3
let $LC_ALL = old_lc_all
let $LC_MESSAGES = old_lc_messages
if len ( env_save )
if len ( env_save )
for key in keys ( env_save )
for key in keys ( env_save )
exec 'let $' . key . ' = ' . string ( env_save [key ])
exec ute 'let $' . key . ' = ' . string ( env_save [key ])
endfor
endfor
endif
endif
" }}}3
" }}}3
@ -540,10 +545,9 @@ function! SyntasticMake(options) " {{{2
" restore options {{{3
" restore options {{{3
let &errorformat = old_errorformat
let &errorformat = old_errorformat
let &l :errorformat = old_local_errorformat
let &l :errorformat = old_local_errorformat
let &shellredir = old_shellredir
" }}}3
" }}}3
if ! s :_running_windows && ( s :_os_name ( ) = ~ "FreeBSD" | | s :_os_name ( ) = ~ "OpenBSD" )
if ! s :_running_windows && ( s :_os_name ( ) = ~ ? 'FreeBSD' | | s :_os_name ( ) = ~ ? 'OpenBSD' )
call syntastic #util #redraw ( g :syntastic_full_redraws )
call syntastic #util #redraw ( g :syntastic_full_redraws )
endif
endif
@ -582,7 +586,7 @@ endfunction " }}}2
"g:syntastic_stl_format
"g:syntastic_stl_format
"
"
"return '' if no errors are cached for the buffer
"return '' if no errors are cached for the buffer
function ! SyntasticStatuslineFlag ( ) " {{{2
function ! SyntasticStatuslineFlag ( ) abort " {{{2
return g :SyntasticLoclist .current ( ) .getStatuslineFlag ( )
return g :SyntasticLoclist .current ( ) .getStatuslineFlag ( )
endfunction " }}}2
endfunction " }}}2
@ -590,12 +594,12 @@ endfunction " }}}2
" Utilities {{{1
" Utilities {{{1
function ! s :_resolve_filetypes ( filetypes ) " {{{2
function ! s :_resolve_filetypes ( filetypes ) abort " {{{2
let type = len ( a :filetypes ) ? a :filetypes [0 ] : &filetype
let type = len ( a :filetypes ) ? a :filetypes [0 ] : &filetype
return split ( get ( g :syntastic_filetype_map , type , type ) , '\m\.' )
return split ( get ( g :syntastic_filetype_map , type , type ) , '\m\.' )
endfunction " }}}2
endfunction " }}}2
function ! s :_ignore_file ( filename ) " {{{2
function ! s :_ignore_file ( filename ) abort " {{{2
let fname = fnamemodify ( a :filename , ':p' )
let fname = fnamemodify ( a :filename , ':p' )
for pattern in g :syntastic_ignore_files
for pattern in g :syntastic_ignore_files
if fname = ~ # pattern
if fname = ~ # pattern
@ -606,9 +610,9 @@ function! s:_ignore_file(filename) " {{{2
endfunction " }}}2
endfunction " }}}2
" Skip running in special buffers
" Skip running in special buffers
function ! s :_skip_file ( ) " {{{2
function ! s :_skip_file ( ) abort " {{{2
let fname = expand ( '%' , 1 )
let fname = expand ( '%' , 1 )
let skip = get ( b :, 'syntastic_skip_checks' , 0 ) | | ( &buftype ! = '' ) | |
let skip = get ( b :, 'syntastic_skip_checks' , 0 ) | | ( &buftype ! = # '' ) | |
\ ! filereadable ( fname ) | | getwinvar ( 0 , '&diff' ) | | s :_ignore_file ( fname ) | |
\ ! filereadable ( fname ) | | getwinvar ( 0 , '&diff' ) | | s :_ignore_file ( fname ) | |
\ fnamemodify ( fname , ':e' ) = ~ ? g :syntastic_ignore_extensions
\ fnamemodify ( fname , ':e' ) = ~ ? g :syntastic_ignore_extensions
if skip
if skip
@ -618,7 +622,7 @@ function! s:_skip_file() " {{{2
endfunction " }}}2
endfunction " }}}2
" Explain why checks will be skipped for the current file
" Explain why checks will be skipped for the current file
function ! s :_explain_skip ( filetypes ) " {{{2
function ! s :_explain_skip ( filetypes ) abort " {{{2
if empty ( a :filetypes ) && s :_skip_file ( )
if empty ( a :filetypes ) && s :_skip_file ( )
let why = []
let why = []
let fname = expand ( '%' , 1 )
let fname = expand ( '%' , 1 )
@ -626,7 +630,7 @@ function! s:_explain_skip(filetypes) " {{{2
if get ( b :, 'syntastic_skip_checks' , 0 )
if get ( b :, 'syntastic_skip_checks' , 0 )
call add ( why , 'b:syntastic_skip_checks set' )
call add ( why , 'b:syntastic_skip_checks set' )
endif
endif
if &buftype ! = ''
if &buftype ! = # ''
call add ( why , 'buftype = ' . string ( &buftype ) )
call add ( why , 'buftype = ' . string ( &buftype ) )
endif
endif
if ! filereadable ( fname )
if ! filereadable ( fname )
@ -647,7 +651,7 @@ function! s:_explain_skip(filetypes) " {{{2
endfunction " }}}2
endfunction " }}}2
" Take a list of errors and add default values to them from a:options
" Take a list of errors and add default values to them from a:options
function ! s :_add_to_errors ( errors , options ) " {{{2
function ! s :_add_to_errors ( errors , options ) abort " {{{2
for err in a :errors
for err in a :errors
for key in keys ( a :options )
for key in keys ( a :options )
if ! has_key ( err , key ) | | empty ( err [key ])
if ! has_key ( err , key ) | | empty ( err [key ])
@ -659,30 +663,8 @@ function! s:_add_to_errors(errors, options) " {{{2
return a :errors
return a :errors
endfunction " }}}2
endfunction " }}}2
" XXX: Is this still needed?
function ! s :_os_name ( ) abort " {{{2
" The script changes &shellredir to stop the screen
return g :_SYNTASTIC_UNAME
" flicking when shelling out to syntax checkers.
function ! s :_bash_hack ( ) " {{{2
if g :syntastic_bash_hack
if ! exists ( 's:shell_is_bash' )
let s :shell_is_bash =
\ ! s :_running_windows &&
\ ( s :_os_name ( ) ! ~ # "FreeBSD" ) && ( s :_os_name ( ) ! ~ # "OpenBSD" ) &&
\ &shell = ~ # '\m\<bash$'
endif
if s :shell_is_bash
let &shellredir = '&>'
endif
endif
endfunction " }}}2
function ! s :_os_name ( ) " {{{2
if ! exists ( 's:_uname' )
let s :_uname = system ( 'uname' )
lockvar s :_uname
endif
return s :_uname
endfunction " }}}2
endfunction " }}}2
" }}}1
" }}}1