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': [] } return { 'exe': '', 'args': [] }
endfunction 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. " Parse a version string. Return an array of version components.
function! syntastic#util#parseVersion(version) function! syntastic#util#parseVersion(version)
return split(matchstr( a:version, '\v^\D*\zs\d+(\.\d+)+\ze' ), '\m\.') 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') call syntastic#log#debugShowVariables(g:SyntasticDebugTrace, 'syntastic_aggregate_errors')
let filetypes = s:ResolveFiletypes() let filetypes = s:ResolveFiletypes()
let aggregate_errors = let aggregate_errors = syntastic#util#var('aggregate_errors')
\ exists('b:syntastic_aggregate_errors') ? b:syntastic_aggregate_errors : g:syntastic_aggregate_errors let decorate_errors = (aggregate_errors || len(filetypes) > 1) && syntastic#util#var('id_checkers')
let decorate_errors = (aggregate_errors || len(filetypes) > 1) &&
\ (exists('b:syntastic_id_checkers') ? b:syntastic_id_checkers : g:syntastic_id_checkers)
for ft in filetypes for ft in filetypes
let clist = empty(a:checkers) ? s:registry.getActiveCheckers(ft) : s:registry.getCheckers(ft, a:checkers) 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 endfunction
function! g:SyntasticBalloonsNotifier.enabled() function! g:SyntasticBalloonsNotifier.enabled()
return return has('balloon_eval') && syntastic#util#var('enable_balloons')
\ has('balloon_eval') &&
\ (exists('b:syntastic_enable_balloons') ? b:syntastic_enable_balloons : g:syntastic_enable_balloons)
endfunction endfunction
" Update the error balloons " Update the error balloons

View File

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

View File

@ -17,7 +17,7 @@ function! g:SyntasticCursorNotifier.New()
endfunction endfunction
function! g:SyntasticCursorNotifier.enabled() 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 endfunction
function! g:SyntasticCursorNotifier.refresh(loclist) function! g:SyntasticCursorNotifier.refresh(loclist)

View File

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

View File

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

View File

@ -40,7 +40,7 @@ set cpo&vim
function! SyntaxCheckers_perl_perl_IsAvailable() dict function! SyntaxCheckers_perl_perl_IsAvailable() dict
" don't call executable() here, to allow things like " don't call executable() here, to allow things like
" let g:syntastic_perl_interpreter='/usr/bin/env perl' " 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 return v:shell_error == 0
endfunction 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') call syntastic#log#deprecationWarn('variable g:syntastic_perl_lib_path should be a list')
let includes = split(g:syntastic_perl_lib_path, ',') let includes = split(g:syntastic_perl_lib_path, ',')
else 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 endif
let shebang = syntastic#util#parseShebang() let shebang = syntastic#util#parseShebang()
let extra = join(map(includes, '"-I" . v:val')) . let extra = join(map(includes, '"-I" . v:val')) .

View File

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