Core: cleanup buffer handling (stage 2).
This commit is contained in:
parent
59cc80a8f7
commit
9648145ab1
@ -21,7 +21,7 @@ function! syntastic#log#warn(msg) abort " {{{2
|
|||||||
endfunction " }}}2
|
endfunction " }}}2
|
||||||
|
|
||||||
function! syntastic#log#error(msg) abort " {{{2
|
function! syntastic#log#error(msg) abort " {{{2
|
||||||
execute "normal \<Esc>"
|
execute 'normal! \<Esc>'
|
||||||
echohl ErrorMsg
|
echohl ErrorMsg
|
||||||
echomsg 'syntastic: error: ' . a:msg
|
echomsg 'syntastic: error: ' . a:msg
|
||||||
echohl None
|
echohl None
|
||||||
|
@ -102,6 +102,10 @@ function! syntastic#util#rmrf(what) abort " {{{2
|
|||||||
endif
|
endif
|
||||||
endfunction " }}}2
|
endfunction " }}}2
|
||||||
|
|
||||||
|
function! syntastic#util#getbufvar(buf, name, ...) abort " {{{2
|
||||||
|
return a:0 ? s:_getbufvar(a:buf, a:name, a:1) : getbufvar(a:buf, a:name)
|
||||||
|
endfunction " }}}2
|
||||||
|
|
||||||
" Search the first 5 lines of the file for a magic number and return a map
|
" Search the first 5 lines of the file for a magic number and return a map
|
||||||
" containing the args and the executable
|
" containing the args and the executable
|
||||||
"
|
"
|
||||||
@ -126,6 +130,16 @@ function! syntastic#util#parseShebang() abort " {{{2
|
|||||||
return { 'exe': '', 'args': [] }
|
return { 'exe': '', 'args': [] }
|
||||||
endfunction " }}}2
|
endfunction " }}}2
|
||||||
|
|
||||||
|
" Get the value of a Vim variable. Allow buffer variables to override global ones.
|
||||||
|
function! syntastic#util#bufRawVar(buf, name, ...) abort " {{{2
|
||||||
|
return s:_getbufvar(a:buf, a:name, get(g:, a:name, a:0 > 0 ? a:1 : ''))
|
||||||
|
endfunction "}}}2
|
||||||
|
|
||||||
|
" Get the value of a syntastic variable. Allow buffer variables to override global ones.
|
||||||
|
function! syntastic#util#bufVar(buf, name, ...) abort " {{{2
|
||||||
|
return call('syntastic#util#bufRawVar', [a:buf, 'syntastic_' . a:name] + a:000)
|
||||||
|
endfunction "}}}2
|
||||||
|
|
||||||
" Get the value of a Vim variable. Allow local variables to override global ones.
|
" Get the value of a Vim variable. Allow local variables to override global ones.
|
||||||
function! syntastic#util#rawVar(name, ...) abort " {{{2
|
function! syntastic#util#rawVar(name, ...) abort " {{{2
|
||||||
return get(b:, a:name, get(g:, a:name, a:0 > 0 ? a:1 : ''))
|
return get(b:, a:name, get(g:, a:name, a:0 > 0 ? a:1 : ''))
|
||||||
@ -165,11 +179,6 @@ function! syntastic#util#compareLexi(a, b) abort " {{{2
|
|||||||
return 0
|
return 0
|
||||||
endfunction " }}}2
|
endfunction " }}}2
|
||||||
|
|
||||||
" strwidth() was added in Vim 7.3; if it doesn't exist, we use strlen()
|
|
||||||
" and hope for the best :)
|
|
||||||
let s:_width = function(exists('*strwidth') ? 'strwidth' : 'strlen')
|
|
||||||
lockvar s:_width
|
|
||||||
|
|
||||||
function! syntastic#util#screenWidth(str, tabstop) abort " {{{2
|
function! syntastic#util#screenWidth(str, tabstop) abort " {{{2
|
||||||
let chunks = split(a:str, "\t", 1)
|
let chunks = split(a:str, "\t", 1)
|
||||||
let width = s:_width(chunks[-1])
|
let width = s:_width(chunks[-1])
|
||||||
@ -391,9 +400,6 @@ function! syntastic#util#setWids() abort " {{{2
|
|||||||
endfor
|
endfor
|
||||||
endfunction " }}}2
|
endfunction " }}}2
|
||||||
|
|
||||||
let s:_str2float = function(exists('*str2float') ? 'str2float' : 'str2nr')
|
|
||||||
lockvar s:_str2float
|
|
||||||
|
|
||||||
function! syntastic#util#str2float(val) abort " {{{2
|
function! syntastic#util#str2float(val) abort " {{{2
|
||||||
return s:_str2float(a:val)
|
return s:_str2float(a:val)
|
||||||
endfunction " }}}2
|
endfunction " }}}2
|
||||||
@ -515,6 +521,11 @@ function! s:_translateElement(key, term) abort " {{{2
|
|||||||
return ret
|
return ret
|
||||||
endfunction " }}}2
|
endfunction " }}}2
|
||||||
|
|
||||||
|
" strwidth() was added in Vim 7.3; if it doesn't exist, we use strlen()
|
||||||
|
" and hope for the best :)
|
||||||
|
let s:_width = function(exists('*strwidth') ? 'strwidth' : 'strlen')
|
||||||
|
lockvar s:_width
|
||||||
|
|
||||||
" @vimlint(EVL103, 1, a:flags)
|
" @vimlint(EVL103, 1, a:flags)
|
||||||
function! s:_delete_dumb(what, flags) abort " {{{2
|
function! s:_delete_dumb(what, flags) abort " {{{2
|
||||||
if !exists('s:rmrf')
|
if !exists('s:rmrf')
|
||||||
@ -561,6 +572,9 @@ function! s:_rmrf(what) abort " {{{2
|
|||||||
endif
|
endif
|
||||||
endfunction " }}}2
|
endfunction " }}}2
|
||||||
|
|
||||||
|
let s:_str2float = function(exists('*str2float') ? 'str2float' : 'str2nr')
|
||||||
|
lockvar s:_str2float
|
||||||
|
|
||||||
function! s:_float2str_smart(val) abort " {{{2
|
function! s:_float2str_smart(val) abort " {{{2
|
||||||
return printf('%.1f', a:val)
|
return printf('%.1f', a:val)
|
||||||
endfunction " }}}2
|
endfunction " }}}2
|
||||||
@ -572,6 +586,18 @@ endfunction " }}}2
|
|||||||
let s:_float2str = function(has('float') ? 's:_float2str_smart' : 's:_float2str_dumb')
|
let s:_float2str = function(has('float') ? 's:_float2str_smart' : 's:_float2str_dumb')
|
||||||
lockvar s:_float2str
|
lockvar s:_float2str
|
||||||
|
|
||||||
|
function! s:_getbufvar_dumb(buf, name, ...) abort " {{{2
|
||||||
|
let ret = getbufvar(a:buf, a:name)
|
||||||
|
if a:0 > 0 && ret ==# ''
|
||||||
|
unlet! ret
|
||||||
|
let ret = a:1
|
||||||
|
endif
|
||||||
|
return ret
|
||||||
|
endfunction "}}}2
|
||||||
|
|
||||||
|
let s:_getbufvar = function(v:version > 703 || (v:version == 703 && has('patch831')) ? 'getbufvar' : 's:_getbufvar_dumb')
|
||||||
|
lockvar s:_getbufvar
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
let &cpo = s:save_cpo
|
||||||
|
@ -19,7 +19,7 @@ if has('reltime')
|
|||||||
lockvar! g:_SYNTASTIC_START
|
lockvar! g:_SYNTASTIC_START
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let g:_SYNTASTIC_VERSION = '3.7.0-226'
|
let g:_SYNTASTIC_VERSION = '3.7.0-227'
|
||||||
lockvar g:_SYNTASTIC_VERSION
|
lockvar g:_SYNTASTIC_VERSION
|
||||||
|
|
||||||
" Sanity checks {{{1
|
" Sanity checks {{{1
|
||||||
@ -136,9 +136,9 @@ let s:_DEBUG_DUMP_OPTIONS = [
|
|||||||
\ 'shellxquote'
|
\ 'shellxquote'
|
||||||
\ ]
|
\ ]
|
||||||
for s:feature in [
|
for s:feature in [
|
||||||
\ 'shellxescape',
|
|
||||||
\ 'shellslash',
|
|
||||||
\ 'autochdir',
|
\ 'autochdir',
|
||||||
|
\ 'shellslash',
|
||||||
|
\ 'shellxescape',
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
if exists('+' . s:feature)
|
if exists('+' . s:feature)
|
||||||
|
@ -15,7 +15,7 @@ function! g:SyntasticChecker.New(args, ...) abort " {{{2
|
|||||||
|
|
||||||
if a:0
|
if a:0
|
||||||
" redirected checker
|
" redirected checker
|
||||||
let newObj._exec = get(a:args, 'exec', a:1['_exec'])
|
let newObj._exec_default = get(a:args, 'exec', a:1['_exec'])
|
||||||
|
|
||||||
let filetype = a:1['_filetype']
|
let filetype = a:1['_filetype']
|
||||||
let name = a:1['_name']
|
let name = a:1['_name']
|
||||||
@ -31,7 +31,7 @@ function! g:SyntasticChecker.New(args, ...) abort " {{{2
|
|||||||
let newObj._enable = a:1['_enable']
|
let newObj._enable = a:1['_enable']
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let newObj._exec = get(a:args, 'exec', newObj._name)
|
let newObj._exec_default = get(a:args, 'exec', newObj._name)
|
||||||
let prefix = 'SyntaxCheckers_' . newObj._filetype . '_' . newObj._name . '_'
|
let prefix = 'SyntaxCheckers_' . newObj._filetype . '_' . newObj._name . '_'
|
||||||
|
|
||||||
if has_key(a:args, 'enable')
|
if has_key(a:args, 'enable')
|
||||||
@ -69,17 +69,9 @@ endfunction " }}}2
|
|||||||
" automatically, but you should keep still this in mind if you change the
|
" automatically, but you should keep still this in mind if you change the
|
||||||
" current checker workflow.
|
" current checker workflow.
|
||||||
function! g:SyntasticChecker.syncExec() abort " {{{2
|
function! g:SyntasticChecker.syncExec() abort " {{{2
|
||||||
let user_exec =
|
let suffix = self._name . '_exec'
|
||||||
\ expand( exists('b:syntastic_' . self._name . '_exec') ? b:syntastic_{self._name}_exec :
|
let user_exec = expand( syntastic#util#var(self._filetype . '_' . suffix, syntastic#util#var(suffix)), 1 )
|
||||||
\ syntastic#util#var(self._filetype . '_' . self._name . '_exec'), 1 )
|
let self._exec = user_exec !=# '' ? user_exec : self._exec_default
|
||||||
|
|
||||||
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
|
|
||||||
endif
|
|
||||||
endfunction " }}}2
|
endfunction " }}}2
|
||||||
|
|
||||||
function! g:SyntasticChecker.getExec() abort " {{{2
|
function! g:SyntasticChecker.getExec() abort " {{{2
|
||||||
@ -187,10 +179,15 @@ endfunction " }}}2
|
|||||||
|
|
||||||
function! g:SyntasticChecker.isAvailable() abort " {{{2
|
function! g:SyntasticChecker.isAvailable() abort " {{{2
|
||||||
call self.syncExec()
|
call self.syncExec()
|
||||||
|
|
||||||
if !has_key(self, '_available')
|
if !has_key(self, '_available')
|
||||||
let self._available = self._isAvailableFunc()
|
let self._available = {}
|
||||||
endif
|
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
|
endfunction " }}}2
|
||||||
|
|
||||||
function! g:SyntasticChecker.isDisabled() abort " {{{2
|
function! g:SyntasticChecker.isDisabled() abort " {{{2
|
||||||
|
@ -29,7 +29,7 @@ endfunction " }}}2
|
|||||||
|
|
||||||
function! g:SyntasticLoclist.current(...) abort " {{{2
|
function! g:SyntasticLoclist.current(...) abort " {{{2
|
||||||
let buf = a:0 > 1 ? a:1 : bufnr('')
|
let buf = a:0 > 1 ? a:1 : bufnr('')
|
||||||
let loclist = getbufvar(buf, 'syntastic_loclist')
|
let loclist = syntastic#util#getbufvar(buf, 'syntastic_loclist', {})
|
||||||
if type(loclist) != type({}) || empty(loclist)
|
if type(loclist) != type({}) || empty(loclist)
|
||||||
unlet! loclist
|
unlet! loclist
|
||||||
let loclist = g:SyntasticLoclist.New([])
|
let loclist = g:SyntasticLoclist.New([])
|
||||||
|
Loading…
Reference in New Issue
Block a user