@ -15,45 +15,53 @@ endif
let g :loaded_syntastic_plugin = 1
let g :loaded_syntastic_plugin = 1
if has ( 'reltime' )
if has ( 'reltime' )
let g :syntastic_start = reltime ( )
let g :_SYNTASTIC_START = reltime ( )
lockvar ! g :syntastic_start
lockvar ! g :_SYNTASTIC_START
endif
endif
let g :syntastic_version = '3.4.0-117 '
let g :_SYNTASTIC_VERSION = '3.6.0-5 '
lockvar g :syntastic_version
lockvar g :_SYNTASTIC_VERSION
" Sanity checks {{{1
" Sanity checks {{{1
for s :feature in ['autocmd' , 'eval' , 'modify_fname' , 'quickfix' , 'reltime' , 'user_commands' ]
for s :feature in [
\ 'autocmd' ,
\ 'eval' ,
\ 'file_in_path' ,
\ 'modify_fname' ,
\ 'quickfix' ,
\ 'reltime' ,
\ '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
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 ! s :_ running_windows && executable ( 'uname' )
try
try
let s : uname = system ( 'uname' )
let s :_ uname = system ( 'uname' )
catch /\m^Vim\%((\a\+)\)\=:E484/
catch /\m^Vim\%((\a\+)\)\=:E484/
call syntastic #log #error ( "your shell " . &shell . " doesn't us e traditional UNIX syntax for redirections")
call syntastic #log #error ( "your shell " . &shell . " can't handl e traditional UNIX syntax for redirections")
finish
finish
endtry
endtry
lockvar s : uname
lockvar s :_ uname
endif
endif
" }}}1
" }}}1
" Defaults {{{1
" Defaults {{{1
let g :syntastic_defaults = {
let g :_SYNTASTIC_DEFAULTS = {
\ 'aggregate_errors' : 0 ,
\ 'aggregate_errors' : 0 ,
\ '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' : 1 ,
\ '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 ,
@ -63,6 +71,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$' ) ,
\ '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 ,
@ -77,11 +86,11 @@ let g:syntastic_defaults = {
\ 'style_warning_symbol' : 'S>' ,
\ 'style_warning_symbol' : 'S>' ,
\ 'warning_symbol' : '>>'
\ 'warning_symbol' : '>>'
\ }
\ }
lockvar ! g :syntastic_defaults
lockvar ! g :_SYNTASTIC_DEFAULTS
for s :key in keys ( g :syntastic_defaults )
for s :key in keys ( g :_SYNTASTIC_DEFAULTS )
if ! exists ( 'g:syntastic_' . s :key )
if ! exists ( 'g:syntastic_' . s :key )
let g :syntastic_ {s :key } = g:syntastic_defaults [s :key ]
let g :syntastic_ {s :key } = copy( g :_SYNTASTIC_DEFAULTS [s :key ])
endif
endif
endfor
endfor
@ -101,7 +110,7 @@ endif
" Debug {{{1
" Debug {{{1
let s :debug_dump_options = [
let s :_DEBUG_DUMP_OPTIONS = [
\ 'shell' ,
\ 'shell' ,
\ 'shellcmdflag' ,
\ 'shellcmdflag' ,
\ 'shellpipe' ,
\ 'shellpipe' ,
@ -112,21 +121,23 @@ let s:debug_dump_options = [
\ 'shellxquote'
\ 'shellxquote'
\ ]
\ ]
if v :version > 703 | | ( v :version = = 703 && has ( 'patch446' ) )
if v :version > 703 | | ( v :version = = 703 && has ( 'patch446' ) )
call add ( s :debug_dump_options , 'shellxescape' )
call add ( s :_DEBUG_DUMP_OPTIONS , 'shellxescape' )
endif
endif
lockvar ! s :debug_dump_options
lockvar ! s :_DEBUG_DUMP_OPTIONS
" debug constants
" debug constants
let g :SyntasticDebugTrace = 1
let g :_SYNTASTIC_DEBUG_TRACE = 1
lockvar g :SyntasticDebugTrace
lockvar g :_SYNTASTIC_DEBUG_TRACE
let g :SyntasticDebugLoclist = 2
let g :_SYNTASTIC_DEBUG_LOCLIST = 2
lockvar g :SyntasticDebugLoclist
lockvar g :_SYNTASTIC_DEBUG_LOCLIST
let g :SyntasticDebugNotifications = 4
let g :_SYNTASTIC_DEBUG_NOTIFICATIONS = 4
lockvar g :SyntasticDebugNotifications
lockvar g :_SYNTASTIC_DEBUG_NOTIFICATIONS
let g :SyntasticDebugAutocommands = 8
let g :_SYNTASTIC_DEBUG_AUTOCOMMANDS = 8
lockvar g :SyntasticDebugAutocommands
lockvar g :_SYNTASTIC_DEBUG_AUTOCOMMANDS
let g :SyntasticDebugVariables = 16
let g :_SYNTASTIC_DEBUG_VARIABLES = 16
lockvar g :SyntasticDebugVariables
lockvar g :_SYNTASTIC_DEBUG_VARIABLES
let g :_SYNTASTIC_DEBUG_CHECKERS = 32
lockvar g :_SYNTASTIC_DEBUG_CHECKERS
" }}}1
" }}}1
@ -143,7 +154,7 @@ let s:modemap = g:SyntasticModeMap.Instance()
" @vimlint(EVL103, 1, a:argLead)
" @vimlint(EVL103, 1, a:argLead)
function ! s :CompleteCheckerName ( argLead , cmdLine , cursorPos ) " {{{2
function ! s :CompleteCheckerName ( argLead , cmdLine , cursorPos ) " {{{2
let checker_names = []
let checker_names = []
for ft in s :resolveFiletypes( )
for ft in s :_resolve_filetypes( [] )
call extend ( checker_names , s :registry .getNamesOfAvailableCheckers ( ft ) )
call extend ( checker_names , s :registry .getNamesOfAvailableCheckers ( ft ) )
endfor
endfor
return join ( checker_names , "\n" )
return join ( checker_names , "\n" )
@ -163,27 +174,56 @@ endfunction " }}}2
" @vimlint(EVL103, 0, a:cmdLine)
" @vimlint(EVL103, 0, a:cmdLine)
" @vimlint(EVL103, 0, a:argLead)
" @vimlint(EVL103, 0, a:argLead)
command ! SyntasticToggleMode call s :ToggleMode ( )
command ! - nargs = * - complete = custom , s :CompleteCheckerName SyntasticCheck call SyntasticCheck ( < f - args > )
command ! - nargs = * - complete = custom , s :CompleteCheckerName SyntasticCheck
command ! - nargs = ? - complete = custom , s :CompleteFiletypes SyntasticInfo call SyntasticInfo ( < f - args > )
\ call s :UpdateErrors ( 0 , < f - args > ) < bar >
command ! Errors call SyntasticErrors ( )
\ call syntastic #util #redraw ( g :syntastic_full_redraws )
command ! SyntasticReset call SyntasticReset ( )
command ! Errors call s :ShowLocList ( )
command ! SyntasticToggleMode call SyntasticToggleMode ( )
command ! - nargs = ? - complete = custom , s :CompleteFiletypes SyntasticInfo
command ! SyntasticSetLoclist call SyntasticSetLoclist ( )
\ call s :modemap .modeInfo ( < f - args > ) |
\ call s :registry .echoInfoFor ( s :resolveFiletypes ( < f - args > ) )
command ! SyntasticReset
\ call s :ClearCache ( ) |
\ call s :notifiers .refresh ( g :SyntasticLoclist .New ( []) )
command ! SyntasticSetLoclist call g :SyntasticLoclist .current ( ) .setloclist ( )
" }}}1
" }}}1
" Autocommands and hooks {{{1
" Public API {{{1
function ! SyntasticCheck ( ...) " {{{2
call s :UpdateErrors ( 0 , a :000 )
call syntastic #util #redraw ( g :syntastic_full_redraws )
endfunction " }}}2
function ! SyntasticInfo ( ...) " {{{2
call s :modemap .modeInfo ( a :000 )
call s :registry .echoInfoFor ( s :_resolve_filetypes ( a :000 ) )
call s :_explain_skip ( a :000 )
endfunction " }}}2
function ! SyntasticErrors ( ) " {{{2
call g :SyntasticLoclist .current ( ) .show ( )
endfunction " }}}2
function ! SyntasticReset ( ) " {{{2
call s :ClearCache ( )
call s :notifiers .refresh ( g :SyntasticLoclist .New ( []) )
endfunction " }}}2
function ! SyntasticToggleMode ( ) " {{{2
call s :modemap .toggleMode ( )
call s :ClearCache ( )
call s :notifiers .refresh ( g :SyntasticLoclist .New ( []) )
call s :modemap .echoMode ( )
endfunction " }}}2
function ! SyntasticSetLoclist ( ) " {{{2
call g :SyntasticLoclist .current ( ) .setloclist ( )
endfunction " }}}2
" }}}1
" Autocommands {{{1
augroup syntastic
augroup syntastic
autocmd BufReadPost * call s :BufReadPostHook ( )
autocmd BufReadPost * call s :BufReadPostHook ( )
autocmd BufWritePost * call s :BufWritePostHook ( )
autocmd BufWritePost * call s :BufWritePostHook ( )
autocmd BufEnter * call s :BufEnterHook ( )
autocmd BufEnter * call s :BufEnterHook ( )
augroup END
augroup END
if v :version > 703 | | ( v :version = = 703 && has ( 'patch544' ) )
if v :version > 703 | | ( v :version = = 703 && has ( 'patch544' ) )
@ -195,20 +235,20 @@ endif
function ! s :BufReadPostHook ( ) " {{{2
function ! s :BufReadPostHook ( ) " {{{2
if g :syntastic_check_on_open
if g :syntastic_check_on_open
call syntastic #log #debug ( g :SyntasticDebugAutocommands ,
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 ( ) " {{{2
call syntastic #log #debug ( g :SyntasticDebugAutocommands ,
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 ( ) " {{{2
call syntastic #log #debug ( g :SyntasticDebugAutocommands ,
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 = = ''
@ -220,17 +260,19 @@ function! s:BufEnterHook() " {{{2
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 ! 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 ( )
endif
endif
endif
endif
endfunction " }}}2
endfunction " }}}2
function ! s :QuitPreHook ( ) " {{{2
function ! s :QuitPreHook ( ) " {{{2
call syntastic #log #debug ( g :SyntasticDebugAutocommands ,
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 = ! g :syntastic_check_on_wq
let b :syntastic_skip_checks = get ( b :, 'syntastic_skip_checks' , 0 ) | | ! syntastic #util #var ( 'check_on_wq' )
call SyntasticLoclistHide ( )
if get ( w :, 'syntastic_loclist_set' , 0 )
call SyntasticLoclistHide ( )
endif
endfunction " }}}2
endfunction " }}}2
" }}}1
" }}}1
@ -238,40 +280,46 @@ 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 , ... ) " {{{2
function ! s :UpdateErrors ( auto_invoked , checker_names ) " {{{2
call syntastic #log #debugShowVariables ( g :SyntasticDebugTrace , 'version' )
call syntastic #log #debugShowVariables ( g :_SYNTASTIC_DEBUG_TRACE , 'version' )
call syntastic #log #debugShowOptions ( g :SyntasticDebugTrace, s :debug_dump_options )
call syntastic #log #debugShowOptions ( g :_SYNTASTIC_DEBUG_TRACE, s :_DEBUG_DUMP_OPTIONS )
call syntastic #log #debugDump ( g :SyntasticDebugVariables )
call syntastic #log #debugDump ( g :_SYNTASTIC_DEBUG_VARIABLES )
call syntastic #log #debug ( g :SyntasticDebugTrace , 'UpdateErrors' . ( a :auto_invoked ? ' (auto)' : '' ) .
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_TRACE , 'UpdateErrors' . ( a :auto_invoked ? ' (auto)' : '' ) .
\ ': ' . ( a:0 ? join ( a :000 ) : 'default checkers' ) )
\ ': ' . ( len( a :checker_names ) ? join ( a :checker_names ) : 'default checkers' ) )
if s :skipF ile( )
if s :_skip_f ile( )
return
return
endif
endif
call s :modemap .synch ( )
call s :modemap .synch ( )
let run_checks = ! a :auto_invoked | | s :modemap .allowsAutoChecking( &filetype )
let run_checks = ! a :auto_invoked | | s :modemap .doAutoChecking( )
if run_checks
if run_checks
call s :CacheErrors ( a :000 )
call s :CacheErrors ( a :checker_names )
endif
endif
let loclist = g :SyntasticLoclist .current ( )
let loclist = g :SyntasticLoclist .current ( )
if exists ( '*SyntasticCheckHook' )
call SyntasticCheckHook ( loclist .getRaw ( ) )
endif
" populate loclist and jump {{{3
" populate loclist and jump {{{3
let do_jump = syntastic #util #var ( 'auto_jump' )
let do_jump = syntastic #util #var ( 'auto_jump' ) + 0
if do_jump = = 2
if do_jump = = 2
let first = loclist .getFirstIssue ( )
let do_jump = loclist .getFirstError ( 1 )
let type = get ( first , 'type' , '' )
elseif do_jump = = 3
let do_jump = type = = ? 'E'
let do_jump = loclist .getFirstError ( )
elseif 0 > do_jump | | do_jump > 3
let do_jump = 0
endif
endif
let w :syntastic_loclist_set = 0
let w :syntastic_loclist_set = 0
if syntastic #util #var ( 'always_populate_loc_list' ) | | do_jump
if syntastic #util #var ( 'always_populate_loc_list' ) | | do_jump
call syntastic #log #debug ( g :SyntasticDebugNotifications , 'loclist: setloclist (new)' )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_NOTIFICATIONS , 'loclist: setloclist (new)' )
call setloclist ( 0 , loclist .getRaw ( ) )
call setloclist ( 0 , loclist .getRaw ( ) )
let w :syntastic_loclist_set = 1
let w :syntastic_loclist_set = 1
if run_checks && do_jump && ! loclist .isEmpty ( )
if run_checks && do_jump && ! loclist .isEmpty ( )
call syntastic #log #debug ( g :SyntasticDebugNotifications , 'loclist: jump' )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_NOTIFICATIONS , 'loclist: jump' )
silent ! lrewind
execute ' silent! lrewind ' . do_jump
" XXX: Vim doesn't call autocmd commands in a predictible
" XXX: Vim doesn't call autocmd commands in a predictible
" order, which can lead to missing filetype when jumping
" order, which can lead to missing filetype when jumping
@ -295,18 +343,18 @@ 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 ) " {{{2
call syntastic #log #debug ( g :SyntasticDebugTrace , '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 ( )
let newLoclist = g :SyntasticLoclist .New ( [])
let newLoclist = g :SyntasticLoclist .New ( [])
if ! s :skipF ile( )
if ! s :_skip_f ile( )
" debug logging {{{3
" debug logging {{{3
call syntastic #log #debugShowVariables ( g :SyntasticDebugTrace , 'aggregate_errors' )
call syntastic #log #debugShowVariables ( g :_SYNTASTIC_DEBUG_TRACE , 'aggregate_errors' )
call syntastic #log #debug ( g :SyntasticDebugTrace , 'getcwd() = ' . getcwd ( ) )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_TRACE , 'getcwd() = ' . getcwd ( ) )
" }}}3
" }}}3
let filetypes = s :resolveFiletypes( )
let filetypes = s :_resolve_filetypes( [] )
let aggregate_errors = syntastic #util #var ( 'aggregate_errors' ) | | len ( filetypes ) > 1
let aggregate_errors = syntastic #util #var ( 'aggregate_errors' ) | | len ( filetypes ) > 1
let decorate_errors = aggregate_errors && syntastic #util #var ( 'id_checkers' )
let decorate_errors = aggregate_errors && syntastic #util #var ( 'id_checkers' )
let sort_aggregated_errors = aggregate_errors && syntastic #util #var ( 'sort_aggregated_errors' )
let sort_aggregated_errors = aggregate_errors && syntastic #util #var ( 'sort_aggregated_errors' )
@ -321,12 +369,12 @@ function! s:CacheErrors(checker_names) " {{{2
for checker in clist
for checker in clist
let cname = checker .getFiletype ( ) . '/' . checker .getName ( )
let cname = checker .getFiletype ( ) . '/' . checker .getName ( )
if ! checker .isAvailable ( )
if ! checker .isAvailable ( )
call syntastic #log #debug ( g :SyntasticDebugTrace , 'CacheErrors: Checker ' . cname . ' is not available' )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_TRACE , 'CacheErrors: Checker ' . cname . ' is not available' )
let unavailable_checkers + = 1
let unavailable_checkers + = 1
continue
continue
endif
endif
call syntastic #log #debug ( g :SyntasticDebugTrace , 'CacheErrors: Invoking checker: ' . cname )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_TRACE , 'CacheErrors: Invoking checker: ' . cname )
let loclist = checker .getLocList ( )
let loclist = checker .getLocList ( )
@ -335,9 +383,9 @@ function! s:CacheErrors(checker_names) " {{{2
call loclist .decorate ( cname )
call loclist .decorate ( cname )
endif
endif
call add ( names , cname )
call add ( names , cname )
if checker .getW antSort( ) && ! sort_aggregated_errors
if checker .w antSort( ) && ! sort_aggregated_errors
call loclist .sort ( )
call loclist .sort ( )
call syntastic #log #debug ( g :SyntasticDebugLoclist , 'sorted:' , loclist )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_LOCLIST , 'sorted:' , loclist )
endif
endif
let newLoclist = newLoclist .extend ( loclist )
let newLoclist = newLoclist .extend ( loclist )
@ -370,33 +418,21 @@ function! s:CacheErrors(checker_names) " {{{2
call syntastic #log #warn ( 'checkers ' . join ( a :checker_names , ', ' ) . ' are not available' )
call syntastic #log #warn ( 'checkers ' . join ( a :checker_names , ', ' ) . ' are not available' )
endif
endif
else
else
call syntastic #log #debug ( g :SyntasticDebugTrace , 'CacheErrors: no checkers available for ' . &filetype )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_TRACE , 'CacheErrors: no checkers available for ' . &filetype )
endif
endif
endif
endif
" }}}3
" }}}3
call syntastic #log #debug ( g :SyntasticDebugLoclist , 'aggregated:' , newLoclist )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_LOCLIST , 'aggregated:' , newLoclist )
if sort_aggregated_errors
if sort_aggregated_errors
call newLoclist .sort ( )
call newLoclist .sort ( )
call syntastic #log #debug ( g :SyntasticDebugLoclist , 'sorted:' , newLoclist )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_LOCLIST , 'sorted:' , newLoclist )
endif
endif
endif
endif
call newLoclist .deploy ( )
call newLoclist .deploy ( )
endfunction " }}}2
endfunction " }}}2
function ! s :ToggleMode ( ) " {{{2
call s :modemap .toggleMode ( )
call s :ClearCache ( )
call s :UpdateErrors ( 1 )
call s :modemap .echoMode ( )
endfunction " }}}2
"display the cached errors for this buf in the location list
function ! s :ShowLocList ( ) " {{{2
call g :SyntasticLoclist .current ( ) .show ( )
endfunction " }}}2
"Emulates the :lmake command. Sets up the make environment according to the
"Emulates the :lmake command. Sets up the make environment according to the
"options given, runs make, resets the environment, returns the location list
"options given, runs make, resets the environment, returns the location list
"
"
@ -417,10 +453,9 @@ endfunction " }}}2
" '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 ) " {{{2
call syntastic #log #debug ( g :SyntasticDebugTrace , '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_shell = &shell
let old_shellredir = &shellredir
let old_shellredir = &shellredir
let old_local_errorformat = &l :errorformat
let old_local_errorformat = &l :errorformat
let old_errorformat = &errorformat
let old_errorformat = &errorformat
@ -429,7 +464,7 @@ function! SyntasticMake(options) " {{{2
let old_lc_all = $LC_ALL
let old_lc_all = $LC_ALL
" }}}3
" }}}3
call s :bashH ack( )
call s :_bash_h ack( )
if has_key ( a :options , 'errorformat' )
if has_key ( a :options , 'errorformat' )
let &errorformat = a :options ['errorformat' ]
let &errorformat = a :options ['errorformat' ]
@ -465,61 +500,78 @@ function! SyntasticMake(options) " {{{2
endif
endif
" }}}3
" }}}3
call syntastic #log #debug ( g :SyntasticDebugLoclist , 'checker output:' , err_lines )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_LOCLIST , 'checker output:' , err_lines )
" Does it still make sense to go on?
let bailout =
\ syntastic #util #var ( 'exit_checks' ) &&
\ has_key ( a :options , 'returns' ) &&
\ index ( a :options ['returns' ], v :shell_error ) = = -1
if ! bailout
if has_key ( a :options , 'Preprocess' )
let err_lines = call ( a :options ['Preprocess' ], [err_lines ])
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_LOCLIST , 'preprocess (external):' , err_lines )
elseif has_key ( a :options , 'preprocess' )
let err_lines = call ( 'syntastic#preprocess#' . a :options ['preprocess' ], [err_lines ])
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_LOCLIST , 'preprocess:' , err_lines )
endif
lgetexpr err_lines
if has_key ( a :options , 'Preprocess' )
let errors = deepcopy ( getloclist ( 0 ) )
let err_lines = call ( a :options ['Preprocess' ], [err_lines ])
call syntastic #log #debug ( g :SyntasticDebugLoclist , 'preprocess (external):' , err_lines )
elseif has_key ( a :options , 'preprocess' )
let err_lines = call ( 'syntastic#preprocess#' . a :options ['preprocess' ], [err_lines ])
call syntastic #log #debug ( g :SyntasticDebugLoclist , 'preprocess:' , err_lines )
endif
lgetexpr err_lines
let errors = deepcopy ( getloclist ( 0 ) )
if has_key ( a :options , 'cwd' )
execute 'lcd ' . fnameescape ( old_cwd )
endif
if has_key ( a :options , 'cwd' )
try
execute 'lcd ' . fnameescape ( old_cwd )
silent lolder
catch /\m^Vim\%((\a\+)\)\=:E380/
" E380: At bottom of quickfix stack
call setloclist ( 0 , [], 'r' )
catch /\m^Vim\%((\a\+)\)\=:E776/
" E776: No location list
" do nothing
endtry
else
let errors = []
endif
endif
silent ! lolder
" 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
let &shellredir = old_shellredir
let &shell = old_shell
" }}}3
" }}}3
if ! s : running_windows && ( s :u name( ) = ~ "FreeBSD" | | s :u 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
call syntastic #log #debug ( g :SyntasticDebugLoclist , 'raw loclist:' , errors )
if bailout
if has_key ( a :options , 'returns' ) && index ( a :options ['returns' ], v :shell_error ) = = -1
throw 'Syntastic: checker error'
throw 'Syntastic: checker error'
endif
endif
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_LOCLIST , 'raw loclist:' , errors )
if has_key ( a :options , 'defaults' )
if has_key ( a :options , 'defaults' )
call s :addToErrors ( errors , a :options ['defaults' ])
call s :_add_to_e rrors( errors , a :options ['defaults' ])
endif
endif
" Add subtype info if present.
" Add subtype info if present.
if has_key ( a :options , 'subtype' )
if has_key ( a :options , 'subtype' )
call s :addToE rrors( errors , { 'subtype' : a :options ['subtype' ] })
call s :_add_to_e rrors( errors , { 'subtype' : a :options ['subtype' ] })
endif
endif
if has_key ( a :options , 'Postprocess' ) && ! empty ( a :options ['Postprocess' ])
if has_key ( a :options , 'Postprocess' ) && ! empty ( a :options ['Postprocess' ])
for rule in a :options ['Postprocess' ]
for rule in a :options ['Postprocess' ]
let errors = call ( rule , [errors ])
let errors = call ( rule , [errors ])
endfor
endfor
call syntastic #log #debug ( g :SyntasticDebugLoclist , 'postprocess (external):' , errors )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_LOCLIST , 'postprocess (external):' , errors )
elseif has_key ( a :options , 'postprocess' ) && ! empty ( a :options ['postprocess' ])
elseif has_key ( a :options , 'postprocess' ) && ! empty ( a :options ['postprocess' ])
for rule in a :options ['postprocess' ]
for rule in a :options ['postprocess' ]
let errors = call ( 'syntastic#postprocess#' . rule , [errors ])
let errors = call ( 'syntastic#postprocess#' . rule , [errors ])
endfor
endfor
call syntastic #log #debug ( g :SyntasticDebugLoclist , 'postprocess:' , errors )
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_LOCLIST , 'postprocess:' , errors )
endif
endif
return errors
return errors
@ -538,12 +590,12 @@ endfunction " }}}2
" Utilities {{{1
" Utilities {{{1
function ! s :resolveFiletypes( ... ) " {{{2
function ! s :_resolve_filetypes( filetypes ) " {{{2
let type = a:0 ? a :1 : &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 :ignoreF ile( filename ) " {{{2
function ! s :_ignore_f ile( filename ) " {{{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
@ -554,19 +606,48 @@ function! s:ignoreFile(filename) " {{{2
endfunction " }}}2
endfunction " }}}2
" Skip running in special buffers
" Skip running in special buffers
function ! s :skipF ile( ) " {{{2
function ! s :_skip_f ile( ) " {{{2
let fname = expand ( '%' )
let fname = expand ( '%' , 1 )
let skip = ( exists ( 'b:syntastic_skip_checks' ) ? b :syntastic_skip_checks : 0 ) | |
let skip = get ( b :, 'syntastic_skip_checks' , 0 ) | | ( &buftype ! = '' ) | |
\ (&buftype ! = '' ) | | !filereadable ( fname ) | | getwinvar ( 0 , '&diff' ) | |
\ !filereadable ( fname ) | | getwinvar ( 0 , '&diff' ) | | s :_ignore_file ( fname ) | |
\ s:ignoreFile ( fname ) | | fnamemodify( fname , ':e' ) = ~ ? g :syntastic_ignore_extensions
\ fnamemodify( fname , ':e' ) = ~ ? g :syntastic_ignore_extensions
if skip
if skip
call syntastic #log #debug ( g :SyntasticDebugTrace, 'skipFile: skipping ')
call syntastic #log #debug ( g :_SYNTASTIC_DEBUG_TRACE, '_skip_file: skipping checks ')
endif
endif
return skip
return skip
endfunction " }}}2
endfunction " }}}2
" Explain why checks will be skipped for the current file
function ! s :_explain_skip ( filetypes ) " {{{2
if empty ( a :filetypes ) && s :_skip_file ( )
let why = []
let fname = expand ( '%' , 1 )
if get ( b :, 'syntastic_skip_checks' , 0 )
call add ( why , 'b:syntastic_skip_checks set' )
endif
if &buftype ! = ''
call add ( why , 'buftype = ' . string ( &buftype ) )
endif
if ! filereadable ( fname )
call add ( why , 'file not readable / not local' )
endif
if getwinvar ( 0 , '&diff' )
call add ( why , 'diff mode' )
endif
if s :_ignore_file ( fname )
call add ( why , 'filename matching g:syntastic_ignore_files' )
endif
if fnamemodify ( fname , ':e' ) = ~ ? g :syntastic_ignore_extensions
call add ( why , 'extension matching g:syntastic_ignore_extensions' )
endif
echomsg 'The current file will not be checked (' . join ( why , ', ' ) . ')'
endif
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 :addToErrors ( errors , options ) " {{{2
function ! s :_add_to_e rrors( errors , options ) " {{{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 ])
@ -578,31 +659,30 @@ function! s:addToErrors(errors, options) " {{{2
return a :errors
return a :errors
endfunction " }}}2
endfunction " }}}2
" The script changes &shellredir and &shell to stop the screen flicking when
" XXX: Is this still needed?
" shelling out to syntax checkers. Not all OSs support the hacks though.
" The script changes &shellredir to stop the screen
function ! s :bashHack ( ) " {{{2
" flicking when shelling out to syntax checkers.
if ! exists ( 's:bash' )
function ! s :_bash_hack ( ) " {{{2
if ! s :running_windows && ( s :uname ( ) ! ~ # "FreeBSD" ) && ( s :uname ( ) ! ~ # "OpenBSD" )
if g :syntastic_bash_hack
let s :bash =
if ! exists ( 's:shell_is_bash' )
\ executable ( '/usr/local/bin/bash' ) ? '/usr/local/bin/bash' :
let s :shell_is_bash =
\ executable ( '/bin/bash' ) ? '/bin/bash' : ''
\ ! s :_running_windows &&
else
\ ( s :_os_name ( ) ! ~ # "FreeBSD" ) && ( s :_os_name ( ) ! ~ # "OpenBSD" ) &&
let s :bash = ' '
\ &shell = ~ # '\m\<bash$ '
endif
endif
endif
if g :syntastic_bash_hack && s :bash ! = ''
if s :shell_is_bash
let &shell = s :bash
let &shellredir = '&>'
let &shellredir = '&>'
endif
endif
endif
endfunction " }}}2
endfunction " }}}2
function ! s :u name( ) " {{{2
function ! s :_os_ name( ) " {{{2
if ! exists ( 's: uname')
if ! exists ( 's: _ uname')
let s : uname = system ( 'uname' )
let s :_ uname = system ( 'uname' )
lockvar s : uname
lockvar s :_ uname
endif
endif
return s : uname
return s :_ uname
endfunction " }}}2
endfunction " }}}2
" }}}1
" }}}1