1
0
mirror of https://github.com/amix/vimrc synced 2025-07-21 03: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

@ -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