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

Updated plugins

This commit is contained in:
amix
2016-10-02 13:37:21 +02:00
parent 751af44cbe
commit aad95603ea
60 changed files with 1788 additions and 463 deletions

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif
let g:_SYNTASTIC_VERSION = '3.7.0-193'
let g:_SYNTASTIC_VERSION = '3.7.0-226'
lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1
@ -132,13 +132,19 @@ let s:_DEBUG_DUMP_OPTIONS = [
\ 'shellpipe',
\ 'shellquote',
\ 'shellredir',
\ 'shellslash',
\ 'shelltemp',
\ 'shellxquote'
\ ]
if exists('+shellxescape')
call add(s:_DEBUG_DUMP_OPTIONS, 'shellxescape')
endif
for s:feature in [
\ 'shellxescape',
\ 'shellslash',
\ 'autochdir',
\ ]
if exists('+' . s:feature)
call add(s:_DEBUG_DUMP_OPTIONS, s:feature)
endif
endfor
lockvar! s:_DEBUG_DUMP_OPTIONS
" debug constants
@ -163,6 +169,7 @@ let s:registry = g:SyntasticRegistry.Instance()
let s:notifiers = g:SyntasticNotifiers.Instance()
let s:modemap = g:SyntasticModeMap.Instance()
let s:_check_stack = []
let s:_quit_pre = []
" Commands {{{1
@ -207,7 +214,7 @@ command! SyntasticJavacEditConfig runtime! syntax_checkers/java/*.vim | Synta
" Public API {{{1
function! SyntasticCheck(...) abort " {{{2
call s:UpdateErrors(0, a:000)
call s:UpdateErrors(bufnr(''), 0, a:000)
call syntastic#util#redraw(g:syntastic_full_redraws)
endfunction " }}}2
@ -215,6 +222,8 @@ function! SyntasticInfo(...) abort " {{{2
call s:modemap.modeInfo(a:000)
call s:registry.echoInfoFor(s:_resolve_filetypes(a:000))
call s:_explain_skip(a:000)
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, s:_DEBUG_DUMP_OPTIONS)
call syntastic#log#debugDump(g:_SYNTASTIC_DEBUG_VARIABLES)
endfunction " }}}2
function! SyntasticErrors() abort " {{{2
@ -222,19 +231,19 @@ function! SyntasticErrors() abort " {{{2
endfunction " }}}2
function! SyntasticReset() abort " {{{2
call s:ClearCache()
call s:ClearCache(bufnr(''))
call s:notifiers.refresh(g:SyntasticLoclist.New([]))
endfunction " }}}2
function! SyntasticToggleMode() abort " {{{2
call s:modemap.toggleMode()
call s:ClearCache()
call s:ClearCache(bufnr(''))
call s:notifiers.refresh(g:SyntasticLoclist.New([]))
call s:modemap.echoMode()
endfunction " }}}2
function! SyntasticSetLoclist() abort " {{{2
call g:SyntasticLoclist.current().setloclist()
call g:SyntasticLoclist.current().setloclist(0)
endfunction " }}}2
" }}}1
@ -243,54 +252,68 @@ endfunction " }}}2
augroup syntastic
autocmd!
autocmd BufEnter * call s:BufEnterHook()
autocmd VimEnter * call s:VimEnterHook()
autocmd BufEnter * call s:BufEnterHook(expand('<afile>', 1))
autocmd BufWinEnter * call s:BufWinEnterHook(expand('<afile>', 1))
augroup END
if g:syntastic_nested_autocommands
augroup syntastic
autocmd BufReadPost * nested call s:BufReadPostHook()
autocmd BufWritePost * nested call s:BufWritePostHook()
autocmd BufReadPost * nested call s:BufReadPostHook(expand('<afile>', 1))
autocmd BufWritePost * nested call s:BufWritePostHook(expand('<afile>', 1))
augroup END
else
augroup syntastic
autocmd BufReadPost * call s:BufReadPostHook()
autocmd BufWritePost * call s:BufWritePostHook()
autocmd BufReadPost * call s:BufReadPostHook(expand('<afile>', 1))
autocmd BufWritePost * call s:BufWritePostHook(expand('<afile>', 1))
augroup END
endif
if exists('##QuitPre')
" QuitPre was added in Vim 7.3.544
augroup syntastic
autocmd QuitPre * call s:QuitPreHook(expand('<amatch>', 1))
autocmd QuitPre * call s:QuitPreHook(expand('<afile>', 1))
augroup END
endif
function! s:BufReadPostHook() abort " {{{2
if g:syntastic_check_on_open
function! s:BufReadPostHook(fname) abort " {{{2
let buf = syntastic#util#fname2buf(a:fname)
if g:syntastic_check_on_open && buf > 0
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufReadPost, buffer ' . bufnr('') . ' = ' . string(bufname(str2nr(bufnr('')))))
call s:UpdateErrors(1, [])
\ 'autocmd: BufReadPost, buffer ' . buf . ' = ' . string(a:fname))
if index(s:_check_stack, buf) == -1
call add(s:_check_stack, buf)
endif
endif
endfunction " }}}2
function! s:BufWritePostHook() abort " {{{2
function! s:BufWritePostHook(fname) abort " {{{2
let buf = syntastic#util#fname2buf(a:fname)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufWritePost, buffer ' . bufnr('') . ' = ' . string(bufname(str2nr(bufnr('')))))
call s:UpdateErrors(1, [])
\ 'autocmd: BufWritePost, buffer ' . buf . ' = ' . string(a:fname))
call s:UpdateErrors(buf, 1, [])
endfunction " }}}2
function! s:BufEnterHook() abort " {{{2
function! s:BufEnterHook(fname) abort " {{{2
let buf = syntastic#util#fname2buf(a:fname)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufEnter, buffer ' . bufnr('') . ' = ' . string(bufname(str2nr(bufnr('')))) .
\ ', &buftype = ' . string(&buftype))
if &buftype ==# ''
call s:notifiers.refresh(g:SyntasticLoclist.current())
\ 'autocmd: BufEnter, buffer ' . buf . ' = ' . string(a:fname) . ', &buftype = ' . string(&buftype))
if buf > 0 && getbufvar(buf, '&buftype') ==# ''
let idx = index(reverse(copy(s:_check_stack)), buf)
if idx >= 0
if !has('vim_starting')
call remove(s:_check_stack, -idx - 1)
call s:UpdateErrors(buf, 1, [])
endif
elseif &buftype ==# ''
call s:notifiers.refresh(g:SyntasticLoclist.current())
endif
elseif &buftype ==# 'quickfix'
" TODO: this is needed because in recent versions of Vim lclose
" can no longer be called from BufWinLeave
" TODO: at this point there is no b:syntastic_loclist
let loclist = filter(copy(getloclist(0)), 'v:val["valid"] == 1')
let owner = str2nr(getbufvar(bufnr(''), 'syntastic_owner_buffer'))
let owner = str2nr(getbufvar(buf, 'syntastic_owner_buffer'))
let buffers = syntastic#util#unique(map(loclist, 'v:val["bufnr"]') + (owner ? [owner] : []))
if !empty(get(w:, 'syntastic_loclist_set', [])) && !empty(loclist) && empty(filter( buffers, 'syntastic#util#bufIsActive(v:val)' ))
call SyntasticLoclistHide()
@ -298,8 +321,39 @@ function! s:BufEnterHook() abort " {{{2
endif
endfunction " }}}2
function! s:BufWinEnterHook(fname) abort " {{{2
let buf = syntastic#util#fname2buf(a:fname)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufWinEnter, buffer ' . buf . ' = ' . string(a:fname) . ', &buftype = ' . string(&buftype))
if buf > 0 && getbufvar(buf, '&buftype') ==# ''
let idx = index(reverse(copy(s:_check_stack)), buf)
if idx >= 0 && !has('vim_starting')
call remove(s:_check_stack, -idx - 1)
call s:UpdateErrors(buf, 1, [])
endif
endif
endfunction " }}}2
function! s:VimEnterHook() abort " {{{2
let g:syntastic_version =
\ g:_SYNTASTIC_VERSION .
\ ' (Vim ' . v:version . (has('nvim') ? ', Neovim' : '') . ', ' .
\ g:_SYNTASTIC_UNAME .
\ (has('gui') ? ', GUI' : '') . ')'
lockvar g:syntastic_version
let buf = bufnr('')
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: VimEnter, buffer ' . buf . ' = ' . string(bufname(buf)) . ', &buftype = ' . string(&buftype))
let idx = index(reverse(copy(s:_check_stack)), buf)
if idx >= 0 && getbufvar(buf, '&buftype') ==# ''
call remove(s:_check_stack, -idx - 1)
call s:UpdateErrors(buf, 1, [])
endif
endfunction " }}}2
function! s:QuitPreHook(fname) abort " {{{2
let buf = bufnr(fnameescape(a:fname))
let buf = syntastic#util#fname2buf(a:fname)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, 'autocmd: QuitPre, buffer ' . buf . ' = ' . string(a:fname))
if !syntastic#util#var('check_on_wq')
@ -317,7 +371,7 @@ endfunction " }}}2
" Main {{{1
"refresh and redraw all the error info for this buf when saving or reading
function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2
function! s:UpdateErrors(buf, auto_invoked, checker_names) abort " {{{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)
@ -326,21 +380,21 @@ function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2
call s:modemap.synch()
if s:_skip_file()
if s:_skip_file(a:buf)
return
endif
let run_checks = !a:auto_invoked || s:modemap.doAutoChecking()
if run_checks
call s:CacheErrors(a:checker_names)
call syntastic#util#setChangedtick()
call s:CacheErrors(a:buf, a:checker_names)
call syntastic#util#setLastTick(a:buf)
else
if a:auto_invoked
return
endif
endif
let loclist = g:SyntasticLoclist.current()
let loclist = g:SyntasticLoclist.current(a:buf)
if exists('*SyntasticCheckHook')
call SyntasticCheckHook(loclist.getRaw())
@ -356,14 +410,8 @@ function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2
let do_jump = 0
endif
let w:syntastic_loclist_set = []
if syntastic#util#var('always_populate_loc_list') || do_jump
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: setloclist (new)')
call setloclist(0, loclist.getRaw())
if !exists('b:syntastic_changedtick')
call syntastic#util#setChangedtick()
endif
let w:syntastic_loclist_set = [bufnr(''), b:syntastic_changedtick]
call loclist.setloclist(1)
if run_checks && do_jump && !loclist.isEmpty()
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: jump')
execute 'silent! lrewind ' . do_jump
@ -383,21 +431,24 @@ function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2
endfunction " }}}2
"clear the loc list for the buffer
function! s:ClearCache() abort " {{{2
call s:notifiers.reset(g:SyntasticLoclist.current())
call b:syntastic_loclist.destroy()
function! s:ClearCache(buf) abort " {{{2
let loclist = g:SyntasticLoclist.current(a:buf)
call s:notifiers.reset(loclist)
call loclist.destroy()
endfunction " }}}2
"detect and cache all syntax errors in this buffer
function! s:CacheErrors(checker_names) abort " {{{2
function! s:CacheErrors(buf, checker_names) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'CacheErrors: ' .
\ (len(a:checker_names) ? join(a:checker_names) : 'default checkers'))
call s:ClearCache()
call s:ClearCache(a:buf)
let newLoclist = g:SyntasticLoclist.New([])
call newLoclist.setOwner(a:buf)
if !s:_skip_file()
if !s:_skip_file(a:buf)
" debug logging {{{3
call syntastic#log#debugShowVariables(g:_SYNTASTIC_DEBUG_TRACE, 'aggregate_errors')
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TERM = ' . string($TERM))
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$PATH = ' . string($PATH))
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getcwd() = ' . string(getcwd()))
" }}}3
@ -436,7 +487,7 @@ function! s:CacheErrors(checker_names) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_LOCLIST, 'sorted:', loclist)
endif
let newLoclist = newLoclist.extend(loclist)
call newLoclist.extend(loclist)
if !aggregate_errors
break
@ -556,7 +607,7 @@ function! SyntasticMake(options) abort " {{{2
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
noautocmd lgetexpr err_lines
let errors = deepcopy(getloclist(0))
@ -569,6 +620,12 @@ function! SyntasticMake(options) abort " {{{2
catch /\m^Vim\%((\a\+)\)\=:E380/
" E380: At bottom of quickfix stack
call setloclist(0, [], 'r')
try
" Vim 7.4.2200 or later
call setloclist(0, [], 'r', { 'title': '' })
catch /\m^Vim\%((\a\+)\)\=:E\%(118\|731\)/
" do nothing
endtry
catch /\m^Vim\%((\a\+)\)\=:E776/
" E776: No location list
" do nothing
@ -660,10 +717,10 @@ function! s:_is_quitting(buf) abort " {{{2
endfunction " }}}2
" Skip running in special buffers
function! s:_skip_file() abort " {{{2
let fname = expand('%', 1)
let skip = s:_is_quitting(bufnr('%')) || get(b:, 'syntastic_skip_checks', 0) ||
\ (&buftype !=# '') || !filereadable(fname) || getwinvar(0, '&diff') ||
function! s:_skip_file(buf) abort " {{{2
let fname = bufname(a:buf)
let skip = s:_is_quitting(a:buf) || getbufvar(a:buf, 'syntastic_skip_checks') ||
\ (getbufvar(a:buf, '&buftype') !=# '') || !filereadable(fname) || getwinvar(0, '&diff') ||
\ getwinvar(0, '&previewwindow') || s:_ignore_file(fname) ||
\ fnamemodify(fname, ':e') =~? g:syntastic_ignore_extensions
if skip
@ -674,17 +731,19 @@ endfunction " }}}2
" Explain why checks will be skipped for the current file
function! s:_explain_skip(filetypes) abort " {{{2
if empty(a:filetypes) && s:_skip_file()
let buf = bufnr('')
if empty(a:filetypes) && s:_skip_file(buf)
let why = []
let fname = expand('%', 1)
let fname = bufname(buf)
let bt = getbufvar(buf, '&buftype')
if s:_is_quitting(bufnr('%'))
if s:_is_quitting(buf)
call add(why, 'quitting buffer')
endif
if get(b:, 'syntastic_skip_checks', 0)
if getbufvar(buf, 'syntastic_skip_checks')
call add(why, 'b:syntastic_skip_checks set')
endif
if &buftype !=# ''
if bt !=# ''
call add(why, 'buftype = ' . string(&buftype))
endif
if !filereadable(fname)