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

Updated vim plugins

This commit is contained in:
amix
2016-11-09 18:22:55 +01:00
parent aad95603ea
commit 1494e2edfa
81 changed files with 2756 additions and 470 deletions

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif
let g:_SYNTASTIC_VERSION = '3.7.0-226'
let g:_SYNTASTIC_VERSION = '3.8.0-3'
lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1
@ -57,7 +57,7 @@ elseif executable('uname')
try
let g:_SYNTASTIC_UNAME = split(syntastic#util#system('uname'), "\n")[0]
catch /\m^Vim\%((\a\+)\)\=:E484/
call syntastic#log#error("your shell " . syntastic#util#var('shell') . " can't handle traditional UNIX syntax for redirections")
call syntastic#log#error("can't run external programs (misconfigured shell options?)")
finish
catch /\m^Vim\%((\a\+)\)\=:E684/
let g:_SYNTASTIC_UNAME = 'Unknown'
@ -136,9 +136,9 @@ let s:_DEBUG_DUMP_OPTIONS = [
\ 'shellxquote'
\ ]
for s:feature in [
\ 'shellxescape',
\ 'shellslash',
\ 'autochdir',
\ 'shellslash',
\ 'shellxescape',
\ ]
if exists('+' . s:feature)
@ -178,11 +178,20 @@ let s:_quit_pre = []
" @vimlint(EVL103, 1, a:cmdLine)
" @vimlint(EVL103, 1, a:argLead)
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos) abort " {{{2
let checker_names = []
for ft in s:_resolve_filetypes([])
call extend(checker_names, s:registry.getNamesOfAvailableCheckers(ft))
endfor
return join(checker_names, "\n")
let names = []
let sep_idx = stridx(a:argLead, '/')
if sep_idx >= 1
let ft = a:argLead[: sep_idx-1]
call extend(names, map( s:registry.getNamesOfAvailableCheckers(ft), 'ft . "/" . v:val' ))
else
for ft in s:registry.resolveFiletypes(&filetype)
call extend(names, s:registry.getNamesOfAvailableCheckers(ft))
endfor
call extend(names, map( copy(s:registry.getKnownFiletypes()), 'v:val . "/"' ))
endif
return join(names, "\n")
endfunction " }}}2
" @vimlint(EVL103, 0, a:cursorPos)
" @vimlint(EVL103, 0, a:cmdLine)
@ -220,7 +229,7 @@ endfunction " }}}2
function! SyntasticInfo(...) abort " {{{2
call s:modemap.modeInfo(a:000)
call s:registry.echoInfoFor(s:_resolve_filetypes(a:000))
call s:registry.echoInfoFor(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)
@ -312,7 +321,7 @@ function! s:BufEnterHook(fname) abort " {{{2
" 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 loclist = filter(copy(getloclist(0)), 'v:val["valid"]')
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)' ))
@ -384,14 +393,12 @@ function! s:UpdateErrors(buf, auto_invoked, checker_names) abort " {{{2
return
endif
let run_checks = !a:auto_invoked || s:modemap.doAutoChecking()
let run_checks = !a:auto_invoked || s:modemap.doAutoChecking(a:buf)
if run_checks
call s:CacheErrors(a:buf, a:checker_names)
call syntastic#util#setLastTick(a:buf)
else
if a:auto_invoked
return
endif
elseif a:auto_invoked
return
endif
let loclist = g:SyntasticLoclist.current(a:buf)
@ -453,20 +460,17 @@ function! s:CacheErrors(buf, checker_names) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getcwd() = ' . string(getcwd()))
" }}}3
let filetypes = s:_resolve_filetypes([])
let aggregate_errors = syntastic#util#var('aggregate_errors') || len(filetypes) > 1
let clist = s:registry.getCheckers(getbufvar(a:buf, '&filetype'), a:checker_names)
let aggregate_errors =
\ syntastic#util#var('aggregate_errors') || len(syntastic#util#unique(map(copy(clist), 'v:val.getFiletype()'))) > 1
let decorate_errors = aggregate_errors && syntastic#util#var('id_checkers')
let sort_aggregated_errors = aggregate_errors && syntastic#util#var('sort_aggregated_errors')
let clist = []
for type in filetypes
call extend(clist, s:registry.getCheckers(type, a:checker_names))
endfor
let names = []
let unavailable_checkers = 0
for checker in clist
let cname = checker.getFiletype() . '/' . checker.getName()
let cname = checker.getCName()
if !checker.isAvailable()
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'CacheErrors: Checker ' . cname . ' is not available')
let unavailable_checkers += 1
@ -687,11 +691,6 @@ endfunction " }}}2
" Utilities {{{1
function! s:_resolve_filetypes(filetypes) abort " {{{2
let type = len(a:filetypes) ? a:filetypes[0] : &filetype
return split( get(g:syntastic_filetype_map, type, type), '\m\.' )
endfunction " }}}2
function! s:_ignore_file(filename) abort " {{{2
let fname = fnamemodify(a:filename, ':p')
for pattern in g:syntastic_ignore_files

View File

@ -15,7 +15,7 @@ function! g:SyntasticChecker.New(args, ...) abort " {{{2
if a:0
" redirected checker
let newObj._exec = get(a:args, 'exec', a:1['_exec'])
let newObj._exec_default = get(a:args, 'exec', a:1['_exec_default'])
let filetype = a:1['_filetype']
let name = a:1['_name']
@ -31,7 +31,10 @@ function! g:SyntasticChecker.New(args, ...) abort " {{{2
let newObj._enable = a:1['_enable']
endif
else
let newObj._exec = get(a:args, 'exec', newObj._name)
let newObj._exec_default = get(a:args, 'exec', newObj._name)
if newObj._exec_default ==# ''
let newObj._exec_default = '<dummy>'
endif
let prefix = 'SyntaxCheckers_' . newObj._filetype . '_' . newObj._name . '_'
if has_key(a:args, 'enable')
@ -62,23 +65,24 @@ function! g:SyntasticChecker.getName() abort " {{{2
return self._name
endfunction " }}}2
function! g:SyntasticChecker.getCName() abort " {{{2
return self._filetype . '/' . self._name
endfunction " }}}2
" Synchronise _exec with user's setting. Force re-validation if needed.
"
" XXX: This function must be called at least once before calling either
" getExec() or getExecEscaped(). Normally isAvailable() does that for you
" automatically, but you should keep still this in mind if you change the
" current checker workflow.
function! g:SyntasticChecker.syncExec() abort " {{{2
let user_exec =
\ expand( exists('b:syntastic_' . self._name . '_exec') ? b:syntastic_{self._name}_exec :
\ syntastic#util#var(self._filetype . '_' . self._name . '_exec'), 1 )
if user_exec !=# '' && user_exec !=# self._exec
let self._exec = user_exec
if has_key(self, '_available')
" we have a new _exec on the block, it has to be validated
call remove(self, '_available')
endif
function! g:SyntasticChecker.syncExec(...) abort " {{{2
if a:0
let self._exec = a:1
else
let suffix = self._name . '_exec'
let self._exec = expand(
\ syntastic#util#var(self._filetype . '_' . suffix,
\ syntastic#util#var(suffix, self._exec_default)), 1 )
endif
endfunction " }}}2
@ -92,7 +96,7 @@ endfunction " }}}2
function! g:SyntasticChecker.getLocListRaw() abort " {{{2
let checker_start = reltime()
let name = self._filetype . '/' . self._name
let name = self.getCName()
if has_key(self, '_enable')
let status = syntastic#util#var(self._enable, -1)
@ -150,7 +154,7 @@ function! g:SyntasticChecker.getVersion(...) abort " {{{2
call self.setVersion(parsed_ver)
else
call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', split(version_output, "\n", 1))
call syntastic#log#error("checker " . self._filetype . "/" . self._name . ": can't parse version string (abnormal termination?)")
call syntastic#log#error("checker " . self.getCName() . ": can't parse version string (abnormal termination?)")
endif
endif
return get(self, '_version', [])
@ -164,8 +168,8 @@ function! g:SyntasticChecker.setVersion(version) abort " {{{2
endfunction " }}}2
function! g:SyntasticChecker.log(msg, ...) abort " {{{2
let leader = self._filetype . '/' . self._name . ': '
if a:0 > 0
let leader = self.getCName() . ': '
if a:0
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, leader . a:msg, a:1)
else
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, leader . a:msg)
@ -187,10 +191,15 @@ endfunction " }}}2
function! g:SyntasticChecker.isAvailable() abort " {{{2
call self.syncExec()
if !has_key(self, '_available')
let self._available = self._isAvailableFunc()
let self._available = {}
endif
return self._available
if !has_key(self._available, self._exec)
let self._available[self._exec] = self._isAvailableFunc()
endif
return self._available[self._exec]
endfunction " }}}2
function! g:SyntasticChecker.isDisabled() abort " {{{2

View File

@ -10,7 +10,7 @@ let g:SyntasticLoclist = {}
function! g:SyntasticLoclist.New(rawLoclist) abort " {{{2
let newObj = copy(self)
let llist = filter(copy(a:rawLoclist), 'v:val["valid"] == 1')
let llist = filter(copy(a:rawLoclist), 'v:val["valid"]')
for e in llist
if get(e, 'type', '') ==# ''
@ -28,8 +28,8 @@ function! g:SyntasticLoclist.New(rawLoclist) abort " {{{2
endfunction " }}}2
function! g:SyntasticLoclist.current(...) abort " {{{2
let buf = a:0 > 1 ? a:1 : bufnr('')
let loclist = getbufvar(buf, 'syntastic_loclist')
let buf = a:0 ? a:1 : bufnr('')
let loclist = syntastic#util#getbufvar(buf, 'syntastic_loclist', {})
if type(loclist) != type({}) || empty(loclist)
unlet! loclist
let loclist = g:SyntasticLoclist.New([])
@ -281,7 +281,7 @@ endfunction " }}}2
"
"would return all errors for buffer 10.
"
"Note that all comparisons are done with ==?
"Note that all string comparisons are done with ==?
function! g:SyntasticLoclist.filter(filters) abort " {{{2
let conditions = values(map(copy(a:filters), 's:_translate(v:key, v:val)'))
let filter = len(conditions) == 1 ?

View File

@ -29,7 +29,8 @@ function! g:SyntasticModeMap.synch() abort " {{{2
endfunction " }}}2
function! g:SyntasticModeMap.allowsAutoChecking(filetype) abort " {{{2
let fts = split(a:filetype, '\m\.')
let registry = g:SyntasticRegistry.Instance()
let fts = registry.resolveFiletypes(a:filetype)
if self.isPassive()
return self._isOneFiletypeActive(fts)
@ -38,13 +39,13 @@ function! g:SyntasticModeMap.allowsAutoChecking(filetype) abort " {{{2
endif
endfunction " }}}2
function! g:SyntasticModeMap.doAutoChecking() abort " {{{2
let local_mode = get(b:, 'syntastic_mode', '')
function! g:SyntasticModeMap.doAutoChecking(buf) abort " {{{2
let local_mode = getbufvar(a:buf, 'syntastic_mode')
if local_mode ==# 'active' || local_mode ==# 'passive'
return local_mode ==# 'active'
endif
return self.allowsAutoChecking(&filetype)
return self.allowsAutoChecking(getbufvar(a:buf, '&filetype'))
endfunction " }}}2
function! g:SyntasticModeMap.isPassive() abort " {{{2
@ -96,7 +97,7 @@ function! g:SyntasticModeMap.modeInfo(filetypes) abort " {{{2
echomsg 'Local mode: ' . b:syntastic_mode
endif
echomsg 'The current file will ' . (self.doAutoChecking() ? '' : 'not ') . 'be checked automatically'
echomsg 'The current file will ' . (self.doAutoChecking(bufnr('')) ? '' : 'not ') . 'be checked automatically'
endif
endfunction " }}}2

View File

@ -43,6 +43,7 @@ let s:_DEFAULT_CHECKERS = {
\ 'handlebars': ['handlebars'],
\ 'haskell': ['hdevtools', 'hlint'],
\ 'haxe': ['haxe'],
\ 'help': [],
\ 'hss': ['hss'],
\ 'html': ['tidy'],
\ 'jade': ['jade_lint'],
@ -188,24 +189,39 @@ endfunction " }}}2
" not checked for availability (that is, the corresponding IsAvailable() are
" not run).
function! g:SyntasticRegistry.getCheckers(ftalias, hints_list) abort " {{{2
let ft = s:_normalise_filetype(a:ftalias)
call self._loadCheckersFor(ft, 0)
let checkers_map = self._checkerMap[ft]
if empty(checkers_map)
return []
endif
call self._checkDeprecation(ft)
let ftlist = self.resolveFiletypes(a:ftalias)
let names =
\ !empty(a:hints_list) ? syntastic#util#unique(a:hints_list) :
\ exists('b:syntastic_checkers') ? b:syntastic_checkers :
\ exists('g:syntastic_' . ft . '_checkers') ? g:syntastic_{ft}_checkers :
\ get(s:_DEFAULT_CHECKERS, ft, 0)
\ !empty(a:hints_list) ? a:hints_list :
\ exists('b:syntastic_checkers') ? b:syntastic_checkers : []
return type(names) == type([]) ?
\ self._filterCheckersByName(checkers_map, names) : [checkers_map[keys(checkers_map)[0]]]
let cnames = []
if !empty(names)
for name in names
if name !~# '/'
for ft in ftlist
call add(cnames, ft . '/' . name)
endfor
else
call add(cnames, name)
endif
endfor
else
for ft in ftlist
call self._sanityCheck(ft)
let defs =
\ exists('g:syntastic_' . ft . '_checkers') ? g:syntastic_{ft}_checkers :
\ get(s:_DEFAULT_CHECKERS, ft, [])
call extend(cnames, map(copy(defs), 'stridx(v:val, "/") < 0 ? ft . "/" . v:val : v:val' ))
endfor
endif
let cnames = syntastic#util#unique(cnames)
for ft in syntastic#util#unique(map( copy(cnames), 'v:val[: stridx(v:val, "/")-1]' ))
call self._loadCheckersFor(ft, 0)
endfor
return self._filterCheckersByName(cnames)
endfunction " }}}2
" Same as getCheckers(), but keep only the available checkers. This runs the
@ -242,8 +258,12 @@ function! g:SyntasticRegistry.getNamesOfAvailableCheckers(ftalias) abort " {{{2
return keys(filter( copy(self._checkerMap[ft]), 'v:val.isAvailable()' ))
endfunction " }}}2
function! g:SyntasticRegistry.resolveFiletypes(ftalias) abort " {{{2
return map(split( get(g:syntastic_filetype_map, a:ftalias, a:ftalias), '\m\.' ), 's:_normalise_filetype(v:val)')
endfunction " }}}2
function! g:SyntasticRegistry.echoInfoFor(ftalias_list) abort " {{{2
let ft_list = syntastic#util#unique(map( copy(a:ftalias_list), 's:_normalise_filetype(v:val)' ))
let ft_list = syntastic#util#unique(self.resolveFiletypes(empty(a:ftalias_list) ? &filetype : a:ftalias_list[0]))
if len(ft_list) != 1
let available = []
let active = []
@ -257,8 +277,8 @@ function! g:SyntasticRegistry.echoInfoFor(ftalias_list) abort " {{{2
else
let ft = ft_list[0]
let available = self.getNamesOfAvailableCheckers(ft)
let active = map(self.getCheckersAvailable(ft, []), 'v:val.getName()')
let disabled = map(self.getCheckersDisabled(ft, []), 'v:val.getName()')
let active = map(self.getCheckersAvailable(ft, []), 'ft ==# v:val.getFiletype() ? v:val.getName() : v:val.getCName()')
let disabled = map(self.getCheckersDisabled(ft, []), 'ft ==# v:val.getFiletype() ? v:val.getName() : v:val.getCName()')
endif
let cnt = len(available)
@ -274,7 +294,7 @@ function! g:SyntasticRegistry.echoInfoFor(ftalias_list) abort " {{{2
let cnt = len(disabled)
let plural = cnt != 1 ? 's' : ''
if len(disabled)
let cklist = join(sort(disabled))
let cklist = join(sort(disabled, 's:_compare_checker_names'))
echomsg 'Checker' . plural . ' disabled for security reasons: ' . cklist
endif
@ -321,8 +341,20 @@ function! g:SyntasticRegistry._registerChecker(checker) abort " {{{2
let self._checkerMap[ft][name] = a:checker
endfunction " }}}2
function! g:SyntasticRegistry._filterCheckersByName(checkers_map, list) abort " {{{2
return filter( map(copy(a:list), 'get(a:checkers_map, v:val, {})'), '!empty(v:val)' )
function! g:SyntasticRegistry._findChecker(cname) abort " {{{2
let sep_idx = stridx(a:cname, '/')
if sep_idx > 0
let ft = a:cname[: sep_idx-1]
let name = a:cname[sep_idx+1 :]
else
let ft = &filetype
let name = a:cname
endif
return get(self._checkerMap[ft], name, {})
endfunction "}}}2
function! g:SyntasticRegistry._filterCheckersByName(cnames) abort " {{{2
return filter( map(copy(a:cnames), 'self._findChecker(v:val)'), '!empty(v:val)' )
endfunction " }}}2
function! g:SyntasticRegistry._loadCheckersFor(filetype, force) abort " {{{2
@ -338,7 +370,14 @@ function! g:SyntasticRegistry._loadCheckersFor(filetype, force) abort " {{{2
endfunction " }}}2
" Check for obsolete variable g:syntastic_<filetype>_checker
function! g:SyntasticRegistry._checkDeprecation(filetype) abort " {{{2
function! g:SyntasticRegistry._sanityCheck(filetype) abort " {{{2
if exists('g:syntastic_' . a:filetype . '_checkers') &&
\ type(g:syntastic_{a:filetype}_checkers) != type([])
unlet! g:syntastic_{a:filetype}_checkers
call syntastic#log#error('variable g:syntastic_' . a:filetype . '_checkers has to be a list of strings')
endif
if exists('g:syntastic_' . a:filetype . '_checker') &&
\ !exists('g:syntastic_' . a:filetype . '_checkers') &&
\ type(g:syntastic_{a:filetype}_checker) == type('')
@ -375,6 +414,26 @@ function! s:_disabled_by_ycm(filetype) abort " {{{2
return index(s:_YCM_TYPES, a:filetype) >= 0
endfunction " }}}2
function! s:_compare_checker_names(a, b) abort " {{{2
if a:a ==# a:b
return 0
endif
if stridx(a:a, '/') < 0
if stridx(a:b, '/') < 0
return a:a < a:b ? -1 : 1
else
return -1
endif
else
if stridx(a:b, '/') < 0
return 1
else
return a:a < a:b ? -1 : 1
endif
endif
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker: