Add support for buffer versions of makeprgBuild variables.

New utility function syntastic#util#var().  Cleanup.
This commit is contained in:
LCD 47 2014-02-12 21:25:51 +02:00
parent 8df33c80c2
commit 7795dff24b
9 changed files with 26 additions and 27 deletions

View File

@ -52,6 +52,13 @@ function! syntastic#util#parseShebang()
return { 'exe': '', 'args': [] }
endfunction
" Get the value of a variable. Allow local variables to override global ones.
function! syntastic#util#var(name)
return
\ exists('b:syntastic_' . a:name) ? b:syntastic_{a:name} :
\ exists('g:syntastic_' . a:name) ? g:syntastic_{a:name} : ''
endfunction
" Parse a version string. Return an array of version components.
function! syntastic#util#parseVersion(version)
return split(matchstr( a:version, '\v^\D*\zs\d+(\.\d+)+\ze' ), '\m\.')

View File

@ -290,10 +290,8 @@ function! s:CacheErrors(checkers)
call syntastic#log#debugShowVariables(g:SyntasticDebugTrace, 'syntastic_aggregate_errors')
let filetypes = s:ResolveFiletypes()
let aggregate_errors =
\ exists('b:syntastic_aggregate_errors') ? b:syntastic_aggregate_errors : g:syntastic_aggregate_errors
let decorate_errors = (aggregate_errors || len(filetypes) > 1) &&
\ (exists('b:syntastic_id_checkers') ? b:syntastic_id_checkers : g:syntastic_id_checkers)
let aggregate_errors = syntastic#util#var('aggregate_errors')
let decorate_errors = (aggregate_errors || len(filetypes) > 1) && syntastic#util#var('id_checkers')
for ft in filetypes
let clist = empty(a:checkers) ? s:registry.getActiveCheckers(ft) : s:registry.getCheckers(ft, a:checkers)

View File

@ -21,9 +21,7 @@ function! g:SyntasticBalloonsNotifier.New()
endfunction
function! g:SyntasticBalloonsNotifier.enabled()
return
\ has('balloon_eval') &&
\ (exists('b:syntastic_enable_balloons') ? b:syntastic_enable_balloons : g:syntastic_enable_balloons)
return has('balloon_eval') && syntastic#util#var('enable_balloons')
endfunction
" Update the error balloons

View File

@ -76,14 +76,14 @@ function! g:SyntasticChecker.getLocList()
endfunction
function! g:SyntasticChecker.makeprgBuild(opts)
let setting = 'g:syntastic_' . self._filetype . '_' . self._name . '_'
let basename = self._filetype . '_' . self._name . '_'
let parts = []
call extend(parts, self._getOpt(a:opts, setting, 'exe', self.getExecEscaped()))
call extend(parts, self._getOpt(a:opts, setting, 'args', ''))
call extend(parts, self._getOpt(a:opts, setting, 'fname', syntastic#util#shexpand('%')))
call extend(parts, self._getOpt(a:opts, setting, 'post_args', ''))
call extend(parts, self._getOpt(a:opts, setting, 'tail', ''))
call extend(parts, self._getOpt(a:opts, basename, 'exe', self.getExecEscaped()))
call extend(parts, self._getOpt(a:opts, basename, 'args', ''))
call extend(parts, self._getOpt(a:opts, basename, 'fname', syntastic#util#shexpand('%')))
call extend(parts, self._getOpt(a:opts, basename, 'post_args', ''))
call extend(parts, self._getOpt(a:opts, basename, 'tail', ''))
return join(parts)
endfunction
@ -115,11 +115,11 @@ function! g:SyntasticChecker._populateHighlightRegexes(errors)
endif
endfunction
function! g:SyntasticChecker._getOpt(opts, setting, name, default)
let sname = a:setting . a:name
function! g:SyntasticChecker._getOpt(opts, basename, name, default)
let user_val = syntastic#util#var(a:basename . a:name)
let ret = []
call extend( ret, self._shescape(get(a:opts, a:name . '_before', '')) )
call extend( ret, self._shescape(exists(sname) ? {sname} : get(a:opts, a:name, a:default)) )
call extend( ret, self._shescape(user_val != '' ? user_val : get(a:opts, a:name, a:default)) )
call extend( ret, self._shescape(get(a:opts, a:name . '_after', '')) )
return ret

View File

@ -17,7 +17,7 @@ function! g:SyntasticCursorNotifier.New()
endfunction
function! g:SyntasticCursorNotifier.enabled()
return exists('b:syntastic_echo_current_error') ? b:syntastic_echo_current_error : g:syntastic_echo_current_error
return syntastic#util#var('echo_current_error')
endfunction
function! g:SyntasticCursorNotifier.refresh(loclist)

View File

@ -28,9 +28,7 @@ function! g:SyntasticHighlightingNotifier.New()
endfunction
function! g:SyntasticHighlightingNotifier.enabled()
return
\ s:has_highlighting &&
\ (exists('b:syntastic_enable_highlighting') ? b:syntastic_enable_highlighting : g:syntastic_enable_highlighting)
return s:has_highlighting && syntastic#util#var('enable_highlighting')
endfunction
" Sets error highlights in the cuirrent window

View File

@ -48,9 +48,7 @@ function! g:SyntasticSignsNotifier.New()
endfunction
function! g:SyntasticSignsNotifier.enabled()
return
\ has('signs') &&
\ exists('b:syntastic_enable_signs') ? b:syntastic_enable_signs : g:syntastic_enable_signs
return has('signs') && syntastic#util#var('enable_signs')
endfunction
function! g:SyntasticSignsNotifier.refresh(loclist)

View File

@ -40,7 +40,7 @@ set cpo&vim
function! SyntaxCheckers_perl_perl_IsAvailable() dict
" don't call executable() here, to allow things like
" let g:syntastic_perl_interpreter='/usr/bin/env perl'
silent! call system(expand(g:syntastic_perl_interpreter) . ' -e ' . syntastic#util#shescape('exit(0)'))
silent! call system(syntastic#util#shexpand(g:syntastic_perl_interpreter) . ' -e ' . syntastic#util#shescape('exit(0)'))
return v:shell_error == 0
endfunction
@ -63,7 +63,7 @@ function! SyntaxCheckers_perl_perl_GetLocList() dict
call syntastic#log#deprecationWarn('variable g:syntastic_perl_lib_path should be a list')
let includes = split(g:syntastic_perl_lib_path, ',')
else
let includes = copy(exists('b:syntastic_perl_lib_path') ? b:syntastic_perl_lib_path : g:syntastic_perl_lib_path)
let includes = copy(syntastic#util#var('perl_lib_path'))
endif
let shebang = syntastic#util#parseShebang()
let extra = join(map(includes, '"-I" . v:val')) .

View File

@ -54,7 +54,7 @@ function! SyntaxCheckers_yaml_yamlxs_GetLocList() dict
endfunction
function! s:Exe()
return expand(g:syntastic_perl_interpreter)
return syntastic#util#shexpand(g:syntastic_perl_interpreter)
endfunction
function s:Modules()
@ -62,7 +62,7 @@ function s:Modules()
call syntastic#log#deprecationWarn('variable g:syntastic_perl_lib_path should be a list')
let includes = split(g:syntastic_perl_lib_path, ',')
else
let includes = copy(exists('b:syntastic_perl_lib_path') ? b:syntastic_perl_lib_path : g:syntastic_perl_lib_path)
let includes = copy(syntastic#util#var('perl_lib_path'))
endif
return join(map(includes, '"-I" . v:val') + ['-MYAML::XS'])
endfunction