1
0
mirror of https://github.com/amix/vimrc synced 2025-06-24 07:44:59 +08:00

Updated plugins

This commit is contained in:
amix
2015-01-18 12:58:28 +00:00
parent c3ba0f3c06
commit e7a01094b6
274 changed files with 4547 additions and 3075 deletions

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif
let g:_SYNTASTIC_VERSION = '3.5.0-72'
let g:_SYNTASTIC_VERSION = '3.5.0-148'
lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1
@ -154,7 +154,7 @@ let s:modemap = g:SyntasticModeMap.Instance()
" @vimlint(EVL103, 1, a:argLead)
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos) " {{{2
let checker_names = []
for ft in s:resolveFiletypes()
for ft in s:_resolve_filetypes([])
call extend(checker_names, s:registry.getNamesOfAvailableCheckers(ft))
endfor
return join(checker_names, "\n")
@ -174,28 +174,56 @@ endfunction " }}}2
" @vimlint(EVL103, 0, a:cmdLine)
" @vimlint(EVL103, 0, a:argLead)
command! SyntasticToggleMode call s:ToggleMode()
command! -nargs=* -complete=custom,s:CompleteCheckerName SyntasticCheck
\ call s:UpdateErrors(0, <f-args>) <bar>
\ call syntastic#util#redraw(g:syntastic_full_redraws)
command! Errors call s:ShowLocList()
command! -nargs=? -complete=custom,s:CompleteFiletypes SyntasticInfo
\ call s:modemap.modeInfo(<f-args>) <bar>
\ call s:registry.echoInfoFor(s:resolveFiletypes(<f-args>)) <bar>
\ call s:explainSkip(<f-args>)
command! SyntasticReset
\ call s:ClearCache() <bar>
\ call s:notifiers.refresh(g:SyntasticLoclist.New([]))
command! SyntasticSetLoclist call g:SyntasticLoclist.current().setloclist()
command! -nargs=* -complete=custom,s:CompleteCheckerName SyntasticCheck call SyntasticCheck(<f-args>)
command! -nargs=? -complete=custom,s:CompleteFiletypes SyntasticInfo call SyntasticInfo(<f-args>)
command! Errors call SyntasticErrors()
command! SyntasticReset call SyntasticReset()
command! SyntasticToggleMode call SyntasticToggleMode()
command! SyntasticSetLoclist call SyntasticSetLoclist()
" }}}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
autocmd BufReadPost * call s:BufReadPostHook()
autocmd BufReadPost * call s:BufReadPostHook()
autocmd BufWritePost * call s:BufWritePostHook()
autocmd BufEnter * call s:BufEnterHook()
autocmd BufEnter * call s:BufEnterHook()
augroup END
if v:version > 703 || (v:version == 703 && has('patch544'))
@ -209,14 +237,14 @@ function! s:BufReadPostHook() " {{{2
if g:syntastic_check_on_open
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufReadPost, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr("")))))
call s:UpdateErrors(1)
call s:UpdateErrors(1, [])
endif
endfunction " }}}2
function! s:BufWritePostHook() " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufWritePost, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr("")))))
call s:UpdateErrors(1)
call s:UpdateErrors(1, [])
endfunction " }}}2
function! s:BufEnterHook() " {{{2
@ -232,7 +260,7 @@ function! s:BufEnterHook() " {{{2
let loclist = filter(copy(getloclist(0)), 'v:val["valid"] == 1')
let owner = str2nr(getbufvar(bufnr(""), 'syntastic_owner_buffer'))
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()
endif
endif
@ -242,7 +270,9 @@ function! s:QuitPreHook() " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ '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')
call SyntasticLoclistHide()
if get(w:, 'syntastic_loclist_set', 0)
call SyntasticLoclistHide()
endif
endfunction " }}}2
" }}}1
@ -250,30 +280,36 @@ endfunction " }}}2
" Main {{{1
"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:_SYNTASTIC_DEBUG_TRACE, 'version')
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, s:_DEBUG_DUMP_OPTIONS)
call syntastic#log#debugDump(g:_SYNTASTIC_DEBUG_VARIABLES)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'UpdateErrors' . (a:auto_invoked ? ' (auto)' : '') .
\ ': ' . (a:0 ? join(a:000) : 'default checkers'))
if s:skipFile()
\ ': ' . (len(a:checker_names) ? join(a:checker_names) : 'default checkers'))
if s:_skip_file()
return
endif
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
call s:CacheErrors(a:000)
call s:CacheErrors(a:checker_names)
endif
let loclist = g:SyntasticLoclist.current()
if exists('*SyntasticCheckHook')
call SyntasticCheckHook(loclist.getRaw())
endif
" 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
let first = loclist.getFirstIssue()
let type = get(first, 'type', '')
let do_jump = type ==? 'E'
let do_jump = loclist.getFirstError(1)
elseif do_jump == 3
let do_jump = loclist.getFirstError()
elseif 0 > do_jump || do_jump > 3
let do_jump = 0
endif
let w:syntastic_loclist_set = 0
@ -283,7 +319,7 @@ function! s:UpdateErrors(auto_invoked, ...) " {{{2
let w:syntastic_loclist_set = 1
if run_checks && do_jump && !loclist.isEmpty()
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
" order, which can lead to missing filetype when jumping
@ -312,13 +348,13 @@ function! s:CacheErrors(checker_names) " {{{2
call s:ClearCache()
let newLoclist = g:SyntasticLoclist.New([])
if !s:skipFile()
if !s:_skip_file()
" debug logging {{{3
call syntastic#log#debugShowVariables(g:_SYNTASTIC_DEBUG_TRACE, 'aggregate_errors')
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getcwd() = ' . getcwd())
" }}}3
let filetypes = s:resolveFiletypes()
let filetypes = s:_resolve_filetypes([])
let aggregate_errors = syntastic#util#var('aggregate_errors') || len(filetypes) > 1
let decorate_errors = aggregate_errors && syntastic#util#var('id_checkers')
let sort_aggregated_errors = aggregate_errors && syntastic#util#var('sort_aggregated_errors')
@ -397,18 +433,6 @@ function! s:CacheErrors(checker_names) " {{{2
call newLoclist.deploy()
endfunction " }}}2
function! s:ToggleMode() " {{{2
call s:modemap.toggleMode()
call s:ClearCache()
call s:notifiers.refresh(g:SyntasticLoclist.New([]))
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
"options given, runs make, resets the environment, returns the location list
"
@ -440,7 +464,7 @@ function! SyntasticMake(options) " {{{2
let old_lc_all = $LC_ALL
" }}}3
call s:bashHack()
call s:_bash_hack()
if has_key(a:options, 'errorformat')
let &errorformat = a:options['errorformat']
@ -519,7 +543,7 @@ function! SyntasticMake(options) " {{{2
let &shellredir = old_shellredir
" }}}3
if !s:_running_windows && (s:uname() =~ "FreeBSD" || s:uname() =~ "OpenBSD")
if !s:_running_windows && (s:_os_name() =~ "FreeBSD" || s:_os_name() =~ "OpenBSD")
call syntastic#util#redraw(g:syntastic_full_redraws)
endif
@ -530,12 +554,12 @@ function! SyntasticMake(options) " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_LOCLIST, 'raw loclist:', errors)
if has_key(a:options, 'defaults')
call s:addToErrors(errors, a:options['defaults'])
call s:_add_to_errors(errors, a:options['defaults'])
endif
" Add subtype info if present.
if has_key(a:options, 'subtype')
call s:addToErrors(errors, { 'subtype': a:options['subtype'] })
call s:_add_to_errors(errors, { 'subtype': a:options['subtype'] })
endif
if has_key(a:options, 'Postprocess') && !empty(a:options['Postprocess'])
@ -566,12 +590,12 @@ endfunction " }}}2
" Utilities {{{1
function! s:resolveFiletypes(...) " {{{2
let type = a:0 ? a:1 : &filetype
function! s:_resolve_filetypes(filetypes) " {{{2
let type = len(a:filetypes) ? a:filetypes[0] : &filetype
return split( get(g:syntastic_filetype_map, type, type), '\m\.' )
endfunction " }}}2
function! s:ignoreFile(filename) " {{{2
function! s:_ignore_file(filename) " {{{2
let fname = fnamemodify(a:filename, ':p')
for pattern in g:syntastic_ignore_files
if fname =~# pattern
@ -582,22 +606,22 @@ function! s:ignoreFile(filename) " {{{2
endfunction " }}}2
" Skip running in special buffers
function! s:skipFile() " {{{2
let fname = expand('%')
function! s:_skip_file() " {{{2
let fname = expand('%', 1)
let skip = get(b:, 'syntastic_skip_checks', 0) || (&buftype != '') ||
\ !filereadable(fname) || getwinvar(0, '&diff') || s:ignoreFile(fname) ||
\ !filereadable(fname) || getwinvar(0, '&diff') || s:_ignore_file(fname) ||
\ fnamemodify(fname, ':e') =~? g:syntastic_ignore_extensions
if skip
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'skipFile: skipping')
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, '_skip_file: skipping checks')
endif
return skip
endfunction " }}}2
" Explain why checks will be skipped for the current file
function! s:explainSkip(...) " {{{2
if !a:0 && s:skipFile()
function! s:_explain_skip(filetypes) " {{{2
if empty(a:filetypes) && s:_skip_file()
let why = []
let fname = expand('%')
let fname = expand('%', 1)
if get(b:, 'syntastic_skip_checks', 0)
call add(why, 'b:syntastic_skip_checks set')
@ -611,7 +635,7 @@ function! s:explainSkip(...) " {{{2
if getwinvar(0, '&diff')
call add(why, 'diff mode')
endif
if s:ignoreFile(fname)
if s:_ignore_file(fname)
call add(why, 'filename matching g:syntastic_ignore_files')
endif
if fnamemodify(fname, ':e') =~? g:syntastic_ignore_extensions
@ -623,7 +647,7 @@ function! s:explainSkip(...) " {{{2
endfunction " }}}2
" Take a list of errors and add default values to them from a:options
function! s:addToErrors(errors, options) " {{{2
function! s:_add_to_errors(errors, options) " {{{2
for err in a:errors
for key in keys(a:options)
if !has_key(err, key) || empty(err[key])
@ -638,12 +662,12 @@ endfunction " }}}2
" XXX: Is this still needed?
" The script changes &shellredir to stop the screen
" flicking when shelling out to syntax checkers.
function! s:bashHack() " {{{2
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:uname() !~# "FreeBSD") && (s:uname() !~# "OpenBSD") &&
\ (s:_os_name() !~# "FreeBSD") && (s:_os_name() !~# "OpenBSD") &&
\ &shell =~# '\m\<bash$'
endif
@ -653,7 +677,7 @@ function! s:bashHack() " {{{2
endif
endfunction " }}}2
function! s:uname() " {{{2
function! s:_os_name() " {{{2
if !exists('s:_uname')
let s:_uname = system('uname')
lockvar s:_uname

View File

@ -22,10 +22,10 @@ endfunction " }}}2
" Update the error balloons
function! g:SyntasticBalloonsNotifier.refresh(loclist) " {{{2
unlet! b:syntastic_balloons
unlet! b:syntastic_private_balloons
if self.enabled() && !a:loclist.isEmpty()
let b:syntastic_balloons = a:loclist.balloons()
if !empty(b:syntastic_balloons)
let b:syntastic_private_balloons = a:loclist.balloons()
if !empty(b:syntastic_private_balloons)
set ballooneval balloonexpr=SyntasticBalloonsExprNotifier()
endif
endif
@ -34,10 +34,10 @@ endfunction " }}}2
" Reset the error balloons
" @vimlint(EVL103, 1, a:loclist)
function! g:SyntasticBalloonsNotifier.reset(loclist) " {{{2
let b:syntastic_balloons = {}
let b:syntastic_private_balloons = {}
if has('balloon_eval')
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'balloons: reset')
unlet! b:syntastic_balloons
unlet! b:syntastic_private_balloons
set noballooneval
endif
endfunction " }}}2
@ -48,10 +48,10 @@ endfunction " }}}2
" Private functions {{{1
function! SyntasticBalloonsExprNotifier() " {{{2
if !exists('b:syntastic_balloons')
if !exists('b:syntastic_private_balloons')
return ''
endif
return get(b:syntastic_balloons, v:beval_lnum, '')
return get(b:syntastic_private_balloons, v:beval_lnum, '')
endfunction " }}}2
" }}}1

View File

@ -30,7 +30,7 @@ function! g:SyntasticChecker.New(args) " {{{2
if exists('*' . prefix . 'IsAvailable')
let newObj._isAvailableFunc = function(prefix . 'IsAvailable')
else
let newObj._isAvailableFunc = function('SyntasticCheckerIsAvailableDefault')
let newObj._isAvailableFunc = function('s:_isAvailableDefault')
endif
if exists('*' . prefix . 'GetHighlightRegex')
@ -51,7 +51,7 @@ endfunction " }}}2
function! g:SyntasticChecker.getExec() " {{{2
return
\ expand( exists('b:syntastic_' . self._name . '_exec') ? b:syntastic_{self._name}_exec :
\ syntastic#util#var(self._filetype . '_' . self._name . '_exec', self._exec) )
\ syntastic#util#var(self._filetype . '_' . self._name . '_exec', self._exec), 1 )
endfunction " }}}2
function! g:SyntasticChecker.getExecEscaped() " {{{2
@ -162,28 +162,18 @@ endfunction " }}}2
function! g:SyntasticChecker._getOpt(opts, basename, name, default) " {{{2
let ret = []
call extend( ret, self._shescape(get(a:opts, a:name . '_before', '')) )
call extend( ret, self._shescape(syntastic#util#var( a:basename . a:name, get(a:opts, a:name, a:default) )) )
call extend( ret, self._shescape(get(a:opts, a:name . '_after', '')) )
call extend( ret, syntastic#util#argsescape(get(a:opts, a:name . '_before', '')) )
call extend( ret, syntastic#util#argsescape(syntastic#util#var( a:basename . a:name, get(a:opts, a:name, a:default) )) )
call extend( ret, syntastic#util#argsescape(get(a:opts, a:name . '_after', '')) )
return ret
endfunction " }}}2
function! g:SyntasticChecker._shescape(opt) " {{{2
if type(a:opt) == type('') && a:opt != ''
return [a:opt]
elseif type(a:opt) == type([])
return map(copy(a:opt), 'syntastic#util#shescape(v:val)')
endif
return []
endfunction " }}}2
" }}}1
" Non-method functions {{{1
" Private functions {{{1
function! SyntasticCheckerIsAvailableDefault() dict " {{{2
function! s:_isAvailableDefault() dict " {{{2
return executable(self.getExec())
endfunction " }}}2

View File

@ -19,8 +19,8 @@ endfunction " }}}2
function! g:SyntasticCursorNotifier.refresh(loclist) " {{{2
if self.enabled() && !a:loclist.isEmpty()
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'cursor: refresh')
let b:syntastic_messages = copy(a:loclist.messages(bufnr('')))
let b:syntastic_line = -1
let b:syntastic_private_messages = copy(a:loclist.messages(bufnr('')))
let b:syntastic_private_line = -1
let b:syntastic_cursor_columns = a:loclist.getCursorColumns()
autocmd! syntastic CursorMoved
autocmd syntastic CursorMoved * call SyntasticRefreshCursor()
@ -31,26 +31,26 @@ endfunction " }}}2
function! g:SyntasticCursorNotifier.reset(loclist) " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'cursor: reset')
autocmd! syntastic CursorMoved
unlet! b:syntastic_messages
let b:syntastic_line = -1
unlet! b:syntastic_private_messages
let b:syntastic_private_line = -1
endfunction " }}}2
" @vimlint(EVL103, 0, a:loclist)
" }}}1
" Private methods {{{1
" Private functions {{{1
function! SyntasticRefreshCursor() " {{{2
if !exists('b:syntastic_messages') || empty(b:syntastic_messages)
if !exists('b:syntastic_private_messages') || empty(b:syntastic_private_messages)
" file not checked
return
endif
if !exists('b:syntastic_line')
let b:syntastic_line = -1
if !exists('b:syntastic_private_line')
let b:syntastic_private_line = -1
endif
let l = line('.')
let current_messages = get(b:syntastic_messages, l, {})
let current_messages = get(b:syntastic_private_messages, l, {})
if !exists('b:syntastic_cursor_columns')
let b:syntastic_cursor_columns = g:syntastic_cursor_columns
@ -58,28 +58,28 @@ function! SyntasticRefreshCursor() " {{{2
if b:syntastic_cursor_columns
let c = virtcol('.')
if !exists('b:syntastic_idx')
let b:syntastic_idx = -1
if !exists('b:syntastic_private_idx')
let b:syntastic_private_idx = -1
endif
if s:_isSameIndex(l, b:syntastic_line, c, b:syntastic_idx, current_messages)
if s:_is_same_index(l, b:syntastic_private_line, c, b:syntastic_private_idx, current_messages)
return
else
let b:syntastic_line = l
let b:syntastic_private_line = l
endif
if !empty(current_messages)
let b:syntastic_idx = s:_findIndex(c, current_messages)
call syntastic#util#wideMsg(current_messages[b:syntastic_idx].text)
let b:syntastic_private_idx = s:_find_index(c, current_messages)
call syntastic#util#wideMsg(current_messages[b:syntastic_private_idx].text)
else
let b:syntastic_idx = -1
let b:syntastic_private_idx = -1
echo
endif
else
if l == b:syntastic_line
if l == b:syntastic_private_line
return
endif
let b:syntastic_line = l
let b:syntastic_private_line = l
if !empty(current_messages)
call syntastic#util#wideMsg(current_messages[0].text)
@ -91,9 +91,9 @@ endfunction " }}}2
" }}}1
" Private functions {{{1
" Utilities {{{1
function! s:_isSameIndex(line, old_line, column, idx, messages) " {{{2
function! s:_is_same_index(line, old_line, column, idx, messages) " {{{2
if a:old_line >= 0 && a:line == a:old_line && a:idx >= 0
if len(a:messages) <= 1
return 1
@ -113,7 +113,7 @@ function! s:_isSameIndex(line, old_line, column, idx, messages) " {{{2
endif
endfunction " }}}2
function! s:_findIndex(column, messages) " {{{2
function! s:_find_index(column, messages) " {{{2
let max = len(a:messages) - 1
if max == 0
return 0

View File

@ -43,10 +43,10 @@ endfunction " }}}2
function! g:SyntasticLoclist.sort() " {{{2
if !self._sorted
for e in self._rawLoclist
call s:_setScreenColumn(e)
call s:_set_screen_column(e)
endfor
call sort(self._rawLoclist, self._columns ? 's:_compareErrorItemsByColumns' : 's:_compareErrorItemsByLines')
call sort(self._rawLoclist, self._columns ? 's:_compare_error_items_by_columns' : 's:_compare_error_items_by_lines')
let self._sorted = 1
endif
@ -133,8 +133,19 @@ function! g:SyntasticLoclist.getStatuslineFlag() " {{{2
return self._stl_flag
endfunction " }}}2
function! g:SyntasticLoclist.getFirstIssue() " {{{2
return get(self._rawLoclist, 0, {})
function! g:SyntasticLoclist.getFirstError(...) " {{{2
let max_issues = len(self._rawLoclist)
if a:0 && a:1 < max_issues
let max_issues = a:1
endif
for idx in range(max_issues)
if get(self._rawLoclist[idx], 'type', '') ==? 'E'
return idx + 1
endif
endfor
return 0
endfunction " }}}2
function! g:SyntasticLoclist.getName() " {{{2
@ -243,9 +254,9 @@ function! g:SyntasticLoclist.messages(buf) " {{{2
for l in keys(self._cachedMessages[b])
if len(self._cachedMessages[b][l]) > 1
for e in self._cachedMessages[b][l]
call s:_setScreenColumn(e)
call s:_set_screen_column(e)
endfor
call sort(self._cachedMessages[b][l], 's:_compareErrorItemsByColumns')
call sort(self._cachedMessages[b][l], 's:_compare_error_items_by_columns')
endif
endfor
endfor
@ -253,7 +264,7 @@ function! g:SyntasticLoclist.messages(buf) " {{{2
for b in keys(self._cachedMessages)
for l in keys(self._cachedMessages[b])
call s:_removeShadowedItems(self._cachedMessages[b][l])
call s:_remove_shadowed_items(self._cachedMessages[b][l])
endfor
endfor
endif
@ -320,7 +331,7 @@ endfunction " }}}2
" }}}1
" Non-method functions {{{1
" Public functions {{{1
function! SyntasticLoclistHide() " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: hide')
@ -329,13 +340,13 @@ endfunction " }}}2
" }}}1
" Private functions {{{1
" Utilities {{{1
function! s:_translate(key, val) " {{{2
return 'get(v:val, ' . string(a:key) . ', "") ==? ' . string(a:val)
endfunction " }}}2
function! s:_setScreenColumn(item) " {{{2
function! s:_set_screen_column(item) " {{{2
if !has_key(a:item, 'scol')
let col = get(a:item, 'col', 0)
if col != 0 && get(a:item, 'vcol', 0) == 0
@ -352,7 +363,7 @@ function! s:_setScreenColumn(item) " {{{2
endif
endfunction " }}}2
function! s:_removeShadowedItems(errors) " {{{2
function! s:_remove_shadowed_items(errors) " {{{2
" keep only the first message at a given column
let i = 0
while i < len(a:errors) - 1
@ -384,7 +395,7 @@ function! s:_removeShadowedItems(errors) " {{{2
endwhile
endfunction " }}}2
function! s:_compareErrorItemsByColumns(a, b) " {{{2
function! s:_compare_error_items_by_columns(a, b) " {{{2
if a:a['bufnr'] != a:b['bufnr']
" group by file
return a:a['bufnr'] - a:b['bufnr']
@ -402,7 +413,7 @@ function! s:_compareErrorItemsByColumns(a, b) " {{{2
endif
endfunction " }}}2
function! s:_compareErrorItemsByLines(a, b) " {{{2
function! s:_compare_error_items_by_lines(a, b) " {{{2
if a:a['bufnr'] != a:b['bufnr']
" group by file
return a:a['bufnr'] - a:b['bufnr']

View File

@ -38,6 +38,15 @@ function! g:SyntasticModeMap.allowsAutoChecking(filetype) " {{{2
endif
endfunction " }}}2
function! g:SyntasticModeMap.doAutoChecking() " {{{2
let local_mode = get(b:, 'syntastic_mode', '')
if local_mode ==# 'active' || local_mode ==# 'passive'
return local_mode ==# 'active'
endif
return self.allowsAutoChecking(&filetype)
endfunction " }}}2
function! g:SyntasticModeMap.isPassive() " {{{2
return self._mode ==# 'passive'
endfunction " }}}2
@ -62,13 +71,13 @@ function! g:SyntasticModeMap.echoMode() " {{{2
echo "Syntastic: " . self._mode . " mode enabled"
endfunction " }}}2
function! g:SyntasticModeMap.modeInfo(...) " {{{2
function! g:SyntasticModeMap.modeInfo(filetypes) " {{{2
echomsg 'Syntastic version: ' . g:_SYNTASTIC_VERSION
let type = a:0 ? a:1 : &filetype
let type = len(a:filetypes) ? a:filetypes[0] : &filetype
echomsg 'Info for filetype: ' . type
call self.synch()
echomsg 'Mode: ' . self._mode
echomsg 'Global mode: ' . self._mode
if self._mode ==# 'active'
if len(self._passiveFiletypes)
let plural = len(self._passiveFiletypes) != 1 ? 's' : ''
@ -81,6 +90,14 @@ function! g:SyntasticModeMap.modeInfo(...) " {{{2
endif
endif
echomsg 'Filetype ' . type . ' is ' . (self.allowsAutoChecking(type) ? 'active' : 'passive')
if !len(a:filetypes)
if exists('b:syntastic_mode') && (b:syntastic_mode ==# 'active' || b:syntastic_mode ==# 'passive')
echomsg 'Local mode: ' . b:syntastic_mode
endif
echomsg 'The current file will ' . (self.doAutoChecking() ? '' : 'not ') . 'be checked automatically'
endif
endfunction " }}}2
" }}}1

View File

@ -34,12 +34,12 @@ function! g:SyntasticNotifiers.refresh(loclist) " {{{2
if !has_key(g:{class}, 'enabled') || self._notifier[type].enabled()
if index(s:_PERSISTENT_NOTIFIERS, type) > -1
" refresh only if loclist has changed since last call
if !exists('b:syntastic_' . type . '_stamp')
let b:syntastic_{type}_stamp = []
if !exists('b:syntastic_private_' . type . '_stamp')
let b:syntastic_private_{type}_stamp = []
endif
if a:loclist.isNewerThan(b:syntastic_{type}_stamp) || a:loclist.isEmpty()
if a:loclist.isNewerThan(b:syntastic_private_{type}_stamp) || a:loclist.isEmpty()
call self._notifier[type].refresh(a:loclist)
let b:syntastic_{type}_stamp = syntastic#util#stamp()
let b:syntastic_private_{type}_stamp = syntastic#util#stamp()
endif
else
call self._notifier[type].refresh(a:loclist)
@ -62,7 +62,7 @@ function! g:SyntasticNotifiers.reset(loclist) " {{{2
" also reset stamps
if index(s:_PERSISTENT_NOTIFIERS, type) > -1
let b:syntastic_{type}_stamp = []
let b:syntastic_private_{type}_stamp = []
endif
endfor
endfunction " }}}2

View File

@ -9,7 +9,6 @@ let s:_DEFAULT_CHECKERS = {
\ 'actionscript':['mxmlc'],
\ 'ada': ['gcc'],
\ 'applescript': ['osacompile'],
\ 'arduino': ['avrgcc'],
\ 'asciidoc': ['asciidoc'],
\ 'asm': ['gcc'],
\ 'bro': ['bro'],
@ -92,7 +91,7 @@ let s:_DEFAULT_CHECKERS = {
\ 'yaml': ['jsyaml'],
\ 'z80': ['z80syntaxchecker'],
\ 'zpt': ['zptlint'],
\ 'zsh': ['zsh', 'shellcheck']
\ 'zsh': ['zsh', 'shellcheck'],
\ }
lockvar! s:_DEFAULT_CHECKERS
@ -108,6 +107,25 @@ let s:_DEFAULT_FILETYPE_MAP = {
\ }
lockvar! s:_DEFAULT_FILETYPE_MAP
let s:_ECLIM_TYPES = [
\ 'c',
\ 'cpp',
\ 'html',
\ 'java',
\ 'php',
\ 'python',
\ 'ruby',
\ ]
lockvar! s:_ECLIM_TYPES
let s:_YCM_TYPES = [
\ 'c',
\ 'cpp',
\ 'objc',
\ 'objcpp',
\ ]
lockvar! s:_YCM_TYPES
let g:SyntasticRegistry = {}
" }}}1
@ -138,7 +156,7 @@ endfunction " }}}2
" not checked for availability (that is, the corresponding IsAvailable() are
" not run).
function! g:SyntasticRegistry.getCheckers(ftalias, hints_list) " {{{2
let ft = s:_normaliseFiletype(a:ftalias)
let ft = s:_normalise_filetype(a:ftalias)
call self._loadCheckersFor(ft)
let checkers_map = self._checkerMap[ft]
@ -181,13 +199,13 @@ function! g:SyntasticRegistry.getKnownFiletypes() " {{{2
endfunction " }}}2
function! g:SyntasticRegistry.getNamesOfAvailableCheckers(ftalias) " {{{2
let ft = s:_normaliseFiletype(a:ftalias)
let ft = s:_normalise_filetype(a:ftalias)
call self._loadCheckersFor(ft)
return keys(filter( copy(self._checkerMap[ft]), 'v:val.isAvailable()' ))
endfunction " }}}2
function! g:SyntasticRegistry.echoInfoFor(ftalias_list) " {{{2
let ft_list = syntastic#util#unique(map( copy(a:ftalias_list), 's:_normaliseFiletype(v:val)' ))
let ft_list = syntastic#util#unique(map( copy(a:ftalias_list), 's:_normalise_filetype(v:val)' ))
if len(ft_list) != 1
let available = []
let active = []
@ -211,6 +229,30 @@ function! g:SyntasticRegistry.echoInfoFor(ftalias_list) " {{{2
let plural = cnt != 1 ? 's' : ''
let cklist = cnt ? join(active) : '-'
echomsg 'Currently enabled checker' . plural . ': ' . cklist
" Eclim feels entitled to mess with syntastic's variables {{{3
if exists(':EclimValidate') && get(g:, 'EclimFileTypeValidate', 1)
let disabled = filter(copy(ft_list), 's:_disabled_by_eclim(v:val)')
let cnt = len(disabled)
if cnt
let plural = cnt != 1 ? 's' : ''
let cklist = join(disabled, ', ')
echomsg 'Checkers for filetype' . plural . ' ' . cklist . ' possibly disabled by Eclim'
endif
endif
" }}}3
" So does YouCompleteMe {{{3
if exists('g:loaded_youcompleteme') && get(g:, 'ycm_show_diagnostics_ui', get(g:, 'ycm_register_as_syntastic_checker', 1))
let disabled = filter(copy(ft_list), 's:_disabled_by_ycm(v:val)')
let cnt = len(disabled)
if cnt
let plural = cnt != 1 ? 's' : ''
let cklist = join(disabled, ', ')
echomsg 'Checkers for filetype' . plural . ' ' . cklist . ' possibly disabled by YouCompleteMe'
endif
endif
" }}}3
endfunction " }}}2
" }}}1
@ -257,17 +299,31 @@ endfunction " }}}2
" }}}1
" Private functions {{{1
" Utilities {{{1
"resolve filetype aliases, and replace - with _ otherwise we cant name
"syntax checker functions legally for filetypes like "gentoo-metadata"
function! s:_normaliseFiletype(ftalias) " {{{2
function! s:_normalise_filetype(ftalias) " {{{2
let ft = get(s:_DEFAULT_FILETYPE_MAP, a:ftalias, a:ftalias)
let ft = get(g:syntastic_filetype_map, ft, ft)
let ft = substitute(ft, '\m-', '_', 'g')
return ft
endfunction " }}}2
function! s:_disabled_by_eclim(filetype) " {{{2
if index(s:_ECLIM_TYPES, a:filetype) >= 0
let lang = toupper(a:filetype[0]) . a:filetype[1:]
let ft = a:filetype !=# 'cpp' ? lang : 'C'
return get(g:, 'Eclim' . lang . 'Validate', 1) && !get(g:, 'Eclim' . ft . 'SyntasticEnabled', 0)
endif
return 0
endfunction " }}}2
function! s:_disabled_by_ycm(filetype) " {{{2
return index(s:_YCM_TYPES, a:filetype) >= 0
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -127,10 +127,10 @@ endfunction " }}}2
" Get all the ids of the SyntaxError signs in the buffer
function! g:SyntasticSignsNotifier._bufSignIds() " {{{2
if !exists("b:syntastic_sign_ids")
let b:syntastic_sign_ids = []
if !exists("b:syntastic_private_sign_ids")
let b:syntastic_private_sign_ids = []
endif
return b:syntastic_sign_ids
return b:syntastic_private_sign_ids
endfunction " }}}2
" }}}1