Cleanup: buffer handling.

This commit is contained in:
LCD 47 2017-02-15 08:48:45 +02:00
parent 53a3db5e3b
commit f660d1074f
40 changed files with 169 additions and 147 deletions

View File

@ -132,9 +132,9 @@ endfunction " }}}2
" returns
"
" {'exe': '/usr/bin/perl', 'args': ['-f', '-bar']}
function! syntastic#util#parseShebang() abort " {{{2
function! syntastic#util#parseShebang(buf) abort " {{{2
for lnum in range(1, 5)
let line = getline(lnum)
let line = get(getbufline(a:buf, lnum), 0, '')
if line =~# '^#!'
let line = substitute(line, '\v^#!\s*(\S+/env(\s+-\S+)*\s+)?', '', '')
let exe = matchstr(line, '\m^\S*\ze')

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif
let g:_SYNTASTIC_VERSION = '3.8.0-21'
let g:_SYNTASTIC_VERSION = '3.8.0-23'
lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1

View File

@ -34,19 +34,20 @@ function! SyntaxCheckers_asm_gcc_IsAvailable() dict " {{{1
endfunction " }}}1
function! SyntaxCheckers_asm_gcc_GetLocList() dict " {{{1
let buf = bufnr('')
return syntastic#c#GetLocList('asm', 'gcc', {
\ 'errorformat':
\ '%-G%f:%s:,' .
\ '%f:%l:%c: %trror: %m,' .
\ '%f:%l:%c: %tarning: %m,' .
\ '%f:%l: %m',
\ 'main_flags': '-x assembler -fsyntax-only' . (g:syntastic_asm_generic ? '' : ' -masm=' . s:GetDialect()) })
\ 'main_flags': '-x assembler -fsyntax-only' . (g:syntastic_asm_generic ? '' : ' -masm=' . s:GetDialect(buf)) })
endfunction " }}}1
" Utilities {{{1
function! s:GetDialect() " {{{2
return syntastic#util#var('asm_dialect', expand('%:e', 1) ==? 'asm' ? 'intel' : 'att')
function! s:GetDialect(buf) " {{{2
return syntastic#util#bufVar(a:buf, 'asm_dialect', fnamemodify(bufname(a:buf), ':e') ==? 'asm' ? 'intel' : 'att')
endfunction " }}}2
" }}}1

View File

@ -23,7 +23,8 @@ if !exists('g:syntastic_pc_lint_config_file')
endif
function! SyntaxCheckers_c_pc_lint_GetLocList() dict
let config = syntastic#util#findFileInParent(g:syntastic_pc_lint_config_file, expand('%:p:h', 1))
let buf = bufnr('')
let config = syntastic#util#findFileInParent(g:syntastic_pc_lint_config_file, fnamemodify(bufname(buf), ':p:h'))
call self.log('config =', config)
" -hFs1 - show filename, add space after messages, try to make message 1 line

View File

@ -31,6 +31,7 @@ function! SyntaxCheckers_cabal_cabal_GetHighlightRegex(item)
endfunction
function! SyntaxCheckers_cabal_cabal_GetLocList() dict
let buf = bufnr('')
let makeprg = self.getExecEscaped() . ' check'
let errorformat =
@ -40,9 +41,9 @@ function! SyntaxCheckers_cabal_cabal_GetLocList() dict
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'cwd': expand('%:p:h', 1),
\ 'cwd': fnamemodify(bufname(buf), ':p:h'),
\ 'preprocess': 'cabal',
\ 'defaults': {'bufnr': bufnr('')} })
\ 'defaults': {'bufnr': buf} })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({

View File

@ -18,7 +18,8 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_cuda_nvcc_GetLocList() dict
let arch_flag = syntastic#util#var('cuda_arch')
let buf = bufnr('')
let arch_flag = syntastic#util#bufVar(buf, 'cuda_arch')
if arch_flag !=# ''
let arch_flag = '-arch=' . arch_flag
call syntastic#log#oneTimeWarn('variable g:syntastic_cuda_arch is deprecated, ' .
@ -27,9 +28,9 @@ function! SyntaxCheckers_cuda_nvcc_GetLocList() dict
let build_opts = {}
let dummy = ''
if index(['h', 'hpp', 'cuh'], expand('%:e', 1), 0, 1) >= 0
if syntastic#util#var('cuda_check_header', 0)
let dummy = expand('%:p:h', 1) . syntastic#util#Slash() . '.syntastic_dummy.cu'
if index(['h', 'hpp', 'cuh'], fnamemodify(bufname(buf), ':e'), 0, 1) >= 0
if syntastic#util#bufVar(buf, 'cuda_check_header', 0)
let dummy = fnamemodify(bufname(buf), ':p:h') . syntastic#util#Slash() . '.syntastic_dummy.cu'
let build_opts = {
\ 'exe_before': 'echo > ' . syntastic#util#shescape(dummy) . ' ;',
\ 'fname_before': '.syntastic_dummy.cu -include' }

View File

@ -44,8 +44,9 @@ function! SyntaxCheckers_d_dmd_IsAvailable() dict " {{{1
endfunction " }}}1
function! SyntaxCheckers_d_dmd_GetLocList() dict " {{{1
let buf = bufnr('')
if !exists('g:syntastic_d_include_dirs')
let g:syntastic_d_include_dirs = s:GetIncludes(self, expand('%:p:h'))
let g:syntastic_d_include_dirs = s:GetIncludes(self, fnamemodify(bufname(buf), ':p:h'))
endif
return syntastic#c#GetLocList('d', 'dmd', {

View File

@ -27,9 +27,10 @@ function! SyntaxCheckers_elixir_elixir_IsAvailable() dict
endfunction
function! SyntaxCheckers_elixir_elixir_GetLocList() dict
let buf = bufnr('')
let make_options = {}
let compile_command = 'elixir'
let mix_file = syntastic#util#findFileInParent('mix.exs', expand('%:p:h', 1))
let mix_file = syntastic#util#findFileInParent('mix.exs', fnamemodify(bufname(buf), ':p:h'))
if filereadable(mix_file)
let compile_command = 'mix compile'

View File

@ -25,11 +25,13 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_erlang_escript_GetLocList() dict
if expand('%:e', 1) ==# 'hrl'
let buf = bufnr('')
if fnamemodify(bufname(buf), ':e') ==# 'hrl'
return []
endif
let shebang = syntastic#util#parseShebang()
let shebang = syntastic#util#parseShebang(buf)
if shebang['exe'] ==# 'escript'
let args = '-s'
let post_args = ''
@ -39,7 +41,7 @@ function! SyntaxCheckers_erlang_escript_GetLocList() dict
endif
let makeprg = self.makeprgBuild({
\ 'args_after': args,
\ 'fname': syntastic#util#shexpand('%:p'),
\ 'fname': syntastic#util#shexpand(fnamemodify(bufname(buf), ':p')),
\ 'post_args_after': post_args })
let errorformat =

View File

@ -31,7 +31,8 @@ function! SyntaxCheckers_eruby_ruby_GetLocList() dict
let s:ruby_new = syntastic#util#versionIsAtLeast(self.getVersion(), [1, 9])
endif
let fname = "'" . escape(expand('%', 1), "\\'") . "'"
let buf = bufnr('')
let fname = "'" . escape(bufname(buf), "\\'") . "'"
" TODO: encodings became useful in ruby 1.9 :)
if s:ruby_new
@ -69,7 +70,7 @@ function! SyntaxCheckers_eruby_ruby_GetLocList() dict
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'env': env,
\ 'defaults': { 'bufnr': bufnr(''), 'vcol': 1 } })
\ 'defaults': { 'bufnr': buf, 'vcol': 1 } })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({

View File

@ -28,8 +28,9 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_glsl_cgc_GetLocList() dict " {{{1
let buf = bufnr('')
let makeprg = self.makeprgBuild({
\ 'args_before': '-oglsl -profile ' . s:GetProfile(),
\ 'args_before': '-oglsl -profile ' . s:GetProfile(buf),
\ 'args': (exists('g:syntastic_glsl_options') ? ' ' . g:syntastic_glsl_options : '') })
let errorformat =
@ -43,27 +44,11 @@ endfunction " }}}1
" Utilities {{{1
function! s:GetProfile() " {{{2
let save_view = winsaveview()
let old_foldenable = &foldenable
let old_lazyredraw = &lazyredraw
let &lazyredraw = 1
let &foldenable = 0
call cursor(1, 1)
let magic = '\m\C^// profile:\s*'
let line = search(magic, 'c')
call winrestview(save_view)
let &foldenable = old_foldenable
let &lazyredraw = old_lazyredraw
if line
let profile = matchstr(getline(line), magic . '\zs.*')
else
let extensions = exists('g:syntastic_glsl_extensions') ? g:syntastic_glsl_extensions : s:glsl_extensions
let profile = get(extensions, tolower(expand('%:e', 1)), 'gpu_vert')
function! s:GetProfile(buf) " {{{2
let profile = matchstr(get(filter(getbufline(a:buf, 1, 100), 'v:val =~# "\\m\\C^//\\s*profile:"'), 0, ''), '\m\C^//\s*profile:\s*\zs.*')
if profile ==# ''
let extensions = syntastic#util#bufVar(a:buf, 'glsl_extensions', s:glsl_extensions)
let profile = get(extensions, tolower(fnamemodify(bufname(a:buf), ':e')), 'gpu_vert')
endif
return profile

View File

@ -30,6 +30,7 @@ function! SyntaxCheckers_go_go_GetLocList() dict
if !exists('s:go_new')
let s:go_new = syntastic#util#versionIsAtLeast(self.getVersion(self.getExecEscaped() . ' version'), [1, 5])
endif
let buf = bufnr('')
" Check with gofmt first, since `go build` and `go test` might not report
" syntax errors in the current file if another file with syntax error is
@ -53,14 +54,14 @@ function! SyntaxCheckers_go_go_GetLocList() dict
" Test files, i.e. files with a name ending in `_test.go`, are not
" compiled by `go build`, therefore `go test` must be called for those.
if match(expand('%', 1), '\m_test\.go$') == -1
let cmd = 'build'
let opts = syntastic#util#var('go_go_build_args', s:go_new ? '-buildmode=archive' : '')
let cleanup = 0
else
if bufname(buf) =~# '\m_test\.go$'
let cmd = 'test -c'
let opts = syntastic#util#var('go_go_test_args', s:go_new ? '-buildmode=archive' : '')
let opts = syntastic#util#bufVar(buf, 'go_go_test_args', s:go_new ? '-buildmode=archive' : '')
let cleanup = 1
else
let cmd = 'build'
let opts = syntastic#util#bufVar(buf, 'go_go_build_args', s:go_new ? '-buildmode=archive' : '')
let cleanup = 0
endif
let opt_str = (type(opts) != type('') || opts !=# '') ? join(syntastic#util#argsescape(opts)) : opts
let makeprg = self.getExecEscaped() . ' ' . cmd . ' ' . opt_str
@ -82,12 +83,12 @@ function! SyntaxCheckers_go_go_GetLocList() dict
let errors = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'cwd': expand('%:p:h', 1),
\ 'cwd': fnamemodify(bufname(buf), ':p:h'),
\ 'env': {'GOGC': 'off'},
\ 'defaults': {'type': 'e'} })
if cleanup
call delete(expand('%:p:h', 1) . syntastic#util#Slash() . expand('%:p:h:t', 1) . '.test')
call delete(fnamemodify(bufname(buf), ':p:h') . syntastic#util#Slash() . fnamemodify(bufname(buf), ':p:h') . '.test')
endif
return errors

View File

@ -19,9 +19,10 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_go_gometalinter_GetLocList() dict
let buf = bufnr('')
let makeprg = self.makeprgBuild({
\ 'args': '-t',
\ 'fname': syntastic#util#shexpand('%:p:h') })
\ 'fname': syntastic#util#shescape(fnamemodify(bufname(buf), ':p:h')) })
let errorformat =
\ '%f:%l:%c:%trror: %m,' .

View File

@ -19,8 +19,9 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_go_gotype_GetLocList() dict
let buf = bufnr('')
let makeprg = self.makeprgBuild({
\ 'args': (expand('%', 1) =~# '\m_test\.go$' ? '-a' : ''),
\ 'args': (bufname(buf) =~# '\m_test\.go$' ? '-a' : ''),
\ 'fname': '.' })
let errorformat =
@ -34,7 +35,7 @@ function! SyntaxCheckers_go_gotype_GetLocList() dict
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'cwd': expand('%:p:h', 1),
\ 'cwd': fnamemodify(bufname(buf), ':p:h'),
\ 'defaults': {'type': 'e'} })
endfunction

View File

@ -19,6 +19,7 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_go_govet_GetLocList() dict
let buf = bufnr('')
let makeprg = self.getExecEscaped() . ' vet'
let errorformat =
@ -33,7 +34,7 @@ function! SyntaxCheckers_go_govet_GetLocList() dict
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'cwd': expand('%:p:h', 1),
\ 'cwd': fnamemodify(bufname(buf), ':p:h'),
\ 'defaults': {'type': 'w'} })
endfunction

View File

@ -25,9 +25,10 @@ function! SyntaxCheckers_haskell_hdevtools_GetLocList() dict
let g:syntastic_haskell_hdevtools_args = g:hdevtools_options
endif
let buf = bufnr('')
let makeprg = self.makeprgBuild({
\ 'exe_after': 'check',
\ 'fname': syntastic#util#shexpand('%:p') })
\ 'fname': syntastic#util#shescape(fnamemodify(bufname(buf), ':p')) })
let errorformat =
\ '%-Z %#,'.

View File

@ -14,8 +14,9 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_haskell_hlint_GetLocList() dict
let buf = bufnr('')
let makeprg = self.makeprgBuild({
\ 'fname': syntastic#util#shexpand('%:p')})
\ 'fname': syntastic#util#shescape(fnamemodify(bufname(buf), ':p')) })
let errorformat =
\ '%E%f:%l:%v: Error while reading hint file\, %m,' .

View File

@ -19,12 +19,10 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_haxe_haxe_GetLocList() dict
if exists('b:vaxe_hxml')
let hxml = b:vaxe_hxml
elseif exists('g:vaxe_hxml')
let hxml = g:vaxe_hxml
else
let hxml = syntastic#util#findGlobInParent('*.hxml', expand('%:p:h', 1))
let buf = bufnr('')
let hxml = syntastic#util#bufRawVar(buf, 'vaxe_hxml')
if hxml ==# ''
let hxml = syntastic#util#findGlobInParent('*.hxml', fnamemodify(bufname(buf), ':p:h'))
endif
let hxml = fnamemodify(hxml, ':p')

View File

@ -31,7 +31,8 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_html_validator_GetLocList() dict
let fname = syntastic#util#shexpand('%')
let buf = bufnr('')
let fname = syntastic#util#shescape(fnamemodify(bufname(buf), ':p'))
let makeprg = self.getExecEscaped() . ' -q -L -s --compressed -F out=gnu -F asciiquotes=yes' .
\ (g:syntastic_html_validator_parser !=# '' ? ' -F parser=' . g:syntastic_html_validator_parser : '') .
\ (g:syntastic_html_validator_nsfilter !=# '' ? ' -F nsfilter=' . g:syntastic_html_validator_nsfilter : '') .

View File

@ -23,8 +23,9 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_html_w3_GetLocList() dict
let buf = bufnr('')
let makeprg = self.getExecEscaped() . ' -q -L -s -F output=json ' .
\ '-F uploaded_file=@' . syntastic#util#shexpand('%:p') . '\;type=text/html ' .
\ '-F uploaded_file=@' . syntastic#util#shescape(fnamemodify(bufname(buf), ':p')) . '\;type=text/html ' .
\ g:syntastic_html_w3_api
let errorformat =

View File

@ -40,6 +40,8 @@ endfunction
function! SyntaxCheckers_java_checkstyle_GetLocList() dict
let buf = bufnr('')
" classpath
if !exists('s:sep')
let s:sep = syntastic#util#isRunningWindows() || has('win32unix') ? ';' : ':'
@ -58,7 +60,7 @@ function! SyntaxCheckers_java_checkstyle_GetLocList() dict
\ '-f', 'xml' ])
" filename
let fname = syntastic#util#shescape( expand('%:p:h', 1) . syntastic#util#Slash() . expand('%:t', 1) )
let fname = syntastic#util#shescape( fnamemodify(bufname(buf), ':p:h') . syntastic#util#Slash() . fnamemodify(bufname(buf), ':t') )
if has('win32unix')
let fname = substitute(syntastic#util#system('cygpath -m ' . fname), '\m\%x00', '', 'g')
endif

View File

@ -223,7 +223,7 @@ endfunction " }}}2
function! s:SaveClasspath() " {{{2
" build classpath from lines
let path = ''
let lines = getline(1, line('$'))
let lines = getline(1, '$')
for l in lines
let path = s:AddToClasspath(path, l)
endfor
@ -281,7 +281,7 @@ endfunction " }}}2
function! s:SaveConfig() " {{{2
" get lines
let lines = getline(1, line('$'))
let lines = getline(1, '$')
if g:syntastic_java_javac_config_file_enabled
" save config file lines
call writefile(lines, expand(g:syntastic_java_javac_config_file, 1))

View File

@ -42,11 +42,12 @@ function! SyntaxCheckers_javascript_closurecompiler_GetLocList() dict
call syntastic#log#deprecationWarn('javascript_closure_compiler_options', 'javascript_closurecompiler_args')
call syntastic#log#deprecationWarn('javascript_closure_compiler_file_list', 'javascript_closurecompiler_file_list')
let flist = expand(get(g:, 'syntastic_javascript_closurecompiler_file_list', ''), 1)
let buf = bufnr('')
let flist = expand(syntastic#util#bufVar(buf, 'javascript_closurecompiler_file_list'), 1)
if filereadable(flist)
let file_list = map( readfile(flist), 'expand(v:var, 1)' )
else
let file_list = [expand('%', 1)]
let file_list = [bufname(buf)]
endif
let makeprg = self.makeprgBuild({

View File

@ -29,7 +29,8 @@ function! SyntaxCheckers_javascript_flow_IsAvailable() dict
endfunction
function! SyntaxCheckers_javascript_flow_GetLocList() dict
if syntastic#util#findFileInParent('.flowconfig', expand('%:p:h', 1)) ==# ''
let buf = bufnr('')
if syntastic#util#findFileInParent('.flowconfig', fnamemodify(bufname(buf), ':p:h')) ==# ''
return []
endif

View File

@ -19,6 +19,7 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_limbo_limbo_GetLocList() dict
let buf = bufnr('')
let include = $INFERNO_HOME !=# '' ? '-I$INFERNO_HOME ' : ''
" don't generate .dis in current dir while checking syntax,
" .dis should be generated by `mk`
@ -27,7 +28,7 @@ function! SyntaxCheckers_limbo_limbo_GetLocList() dict
let makeprg = self.makeprgBuild({ 'args_before': include . '-w' . output })
let errorformat = '%E%f:%l:%m'
if expand('%', 1) =~# '\m\.m$'
if bufname(buf) =~# '\m\.m$'
let errorformat = '%-G%f:%l: near ` EOF ` : no implementation module,' . errorformat
endif

View File

@ -19,9 +19,10 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_nasm_nasm_GetLocList() dict
let buf = bufnr('')
let makeprg = self.makeprgBuild({
\ 'args_after': '-X gnu' .
\ ' -I ' . syntastic#util#shescape(expand('%:p:h', 1) . syntastic#util#Slash()) .
\ ' -I ' . syntastic#util#shescape(fnamemodify(bufname(buf), ':p:h') . syntastic#util#Slash()) .
\ ' ' . syntastic#c#NullOutput() })
let errorformat = '%f:%l: %t%*[^:]: %m'

View File

@ -44,7 +44,8 @@ function! SyntaxCheckers_ocaml_camlp4o_IsAvailable() dict " {{{1
endfunction " }}}1
function! SyntaxCheckers_ocaml_camlp4o_GetLocList() dict " {{{1
let makeprg = s:GetMakeprg()
let buf = bufnr('')
let makeprg = s:GetMakeprg(buf)
if makeprg ==# ''
return []
endif
@ -65,7 +66,7 @@ function! SyntaxCheckers_ocaml_camlp4o_GetLocList() dict " {{{1
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'defaults': {'bufnr': bufnr('')} })
\ 'defaults': {'bufnr': buf} })
for e in loclist
if get(e, 'col', 0) && get(e, 'nr', 0)
@ -79,40 +80,41 @@ endfunction " }}}1
" Utilities {{{1
function! s:GetMakeprg() " {{{2
function! s:GetMakeprg(buf) " {{{2
return
\ g:syntastic_ocaml_use_ocamlc ? g:syntastic_ocaml_use_ocamlc :
\ (g:syntastic_ocaml_use_ocamlbuild && isdirectory('_build')) ? s:GetOcamlcMakeprg() :
\ s:GetOtherMakeprg()
\ (g:syntastic_ocaml_use_ocamlbuild && isdirectory('_build')) ? s:GetOcamlcMakeprg(a:buf) :
\ s:GetOtherMakeprg(a:buf)
endfunction " }}}2
function! s:GetOcamlcMakeprg() " {{{2
function! s:GetOcamlcMakeprg(buf) " {{{2
let build_cmd = g:syntastic_ocaml_use_janestreet_core ?
\ 'ocamlc -I ' . syntastic#util#shexpand(g:syntastic_ocaml_janestreet_core_dir) : 'ocamlc'
let build_cmd .= ' -c ' . syntastic#util#shexpand('%')
let build_cmd .= ' -c ' . syntastic#util#shescape(bufname(a:buf))
return build_cmd
endfunction " }}}2
function! s:GetOcamlBuildMakeprg() " {{{2
function! s:GetOcamlBuildMakeprg(buf) " {{{2
return 'ocamlbuild -quiet -no-log -tag annot,' . s:ocamlpp . ' -no-links -no-hygiene -no-sanitize ' .
\ syntastic#util#shexpand('%:r') . '.cmi'
\ syntastic#util#shexpand(fnamemodify(bufname(a:buf), ':r')) . '.cmi'
endfunction " }}}2
function! s:GetOtherMakeprg() " {{{2
function! s:GetOtherMakeprg(buf) " {{{2
"TODO: give this function a better name?
"
"TODO: should use throw/catch instead of returning an empty makeprg
let extension = expand('%:e', 1)
let fname = bufname(a:buf)
let extension = fnamemodify(fname, ':e')
let makeprg = ''
if stridx(extension, 'mly') >= 0 && executable('menhir')
" ocamlyacc output can't be redirected, so use menhir
let makeprg = 'menhir --only-preprocess ' . syntastic#util#shexpand('%') . ' >' . syntastic#util#DevNull()
let makeprg = 'menhir --only-preprocess ' . syntastic#util#shescape(fname) . ' >' . syntastic#util#DevNull()
elseif stridx(extension,'mll') >= 0 && executable('ocamllex')
let makeprg = 'ocamllex -q ' . syntastic#c#NullOutput() . ' ' . syntastic#util#shexpand('%')
let makeprg = 'ocamllex -q ' . syntastic#c#NullOutput() . ' ' . syntastic#util#shescape(fname)
else
let makeprg = 'camlp4o ' . syntastic#c#NullOutput() . ' ' . syntastic#util#shexpand('%')
let makeprg = 'camlp4o ' . syntastic#c#NullOutput() . ' ' . syntastic#util#shescape(fname)
endif
return makeprg

View File

@ -51,13 +51,14 @@ function! SyntaxCheckers_perl_perl_IsAvailable() dict " {{{1
endfunction " }}}1
function! SyntaxCheckers_perl_perl_GetLocList() dict " {{{1
let buf = bufnr('')
if type(g:syntastic_perl_lib_path) == type('')
call syntastic#log#oneTimeWarn('variable g:syntastic_perl_lib_path should be a list')
let includes = split(g:syntastic_perl_lib_path, ',')
else
let includes = copy(syntastic#util#var('perl_lib_path', []))
let includes = copy(syntastic#util#bufVar(buf, 'perl_lib_path', []))
endif
let shebang = syntastic#util#parseShebang()
let shebang = syntastic#util#parseShebang(buf)
let extra = map(includes, '"-I" . v:val') +
\ (index(shebang['args'], '-T') >= 0 ? ['-T'] : []) +
\ (index(shebang['args'], '-t') >= 0 ? ['-t'] : [])

View File

@ -43,11 +43,13 @@ function! SyntaxCheckers_r_lint_IsAvailable() dict
endfunction
function! SyntaxCheckers_r_lint_GetLocList() dict
let buf = bufnr('')
let setwd = syntastic#util#isRunningWindows() ? 'setwd("' . escape(getcwd(), '"\') . '"); ' : ''
let makeprg = self.getExecEscaped() . ' --slave --restore --no-save' .
\ ' -e ' . syntastic#util#shescape(setwd . 'library(lint); ' .
\ 'try(lint(commandArgs(TRUE), ' . g:syntastic_r_lint_styles . '))') .
\ ' --args ' . syntastic#util#shexpand('%')
\ ' --args ' . syntastic#util#shescape(bufname(buf))
let errorformat =
\ '%t:%f:%l:%v: %m,' .

View File

@ -38,7 +38,7 @@ set cpo&vim
function! SyntaxCheckers_r_lintr_GetHighlightRegex(item)
let term = matchstr(a:item['text'], "\\m'\\zs[^']\\+\\ze'")
return term != '' ? '\V' . escape(term, '\') : ''
return term !=# '' ? '\V' . escape(term, '\') : ''
endfunction
function! SyntaxCheckers_r_lintr_IsAvailable() dict
@ -50,11 +50,13 @@ function! SyntaxCheckers_r_lintr_IsAvailable() dict
endfunction
function! SyntaxCheckers_r_lintr_GetLocList() dict
let buf = bufnr('')
let setwd = syntastic#util#isRunningWindows() ? 'setwd("' . escape(getcwd(), '"\') . '"); ' : ''
let makeprg = self.getExecEscaped() . ' --slave --no-restore --no-save' .
\ ' -e ' . syntastic#util#shescape(setwd . 'suppressPackageStartupMessages(library(lintr)); ' .
\ 'lint(cache = ' . g:syntastic_r_lintr_cache . ', commandArgs(TRUE), ' . g:syntastic_r_lintr_linters . ')') .
\ ' --args ' . syntastic#util#shexpand('%')
\ ' --args ' . syntastic#util#shescape(bufname(buf))
let errorformat =
\ '%W%f:%l:%c: style: %m,' .

View File

@ -46,11 +46,13 @@ function! SyntaxCheckers_r_svtools_IsAvailable() dict
endfunction
function! SyntaxCheckers_r_svtools_GetLocList() dict
let buf = bufnr('')
let setwd = syntastic#util#isRunningWindows() ? 'setwd("' . escape(getcwd(), '"\') . '"); ' : ''
let makeprg = self.getExecEscaped() . ' --slave --restore --no-save' .
\ ' -e ' . syntastic#util#shescape(setwd . 'library(svTools); ' .
\ 'try(lint(commandArgs(TRUE), filename = commandArgs(TRUE), type = "flat", sep = ":"))') .
\ ' --args ' . syntastic#util#shexpand('%')
\ ' --args ' . syntastic#util#shescape(bufname(buf))
let errorformat =
\ '%trror:%f:%\s%#%l:%\s%#%v:%m,' .

View File

@ -26,11 +26,12 @@ augroup syntastic
augroup END
function! SyntaxCheckers_rst_sphinx_GetLocList() dict
let buf = bufnr('')
let srcdir = syntastic#util#var('rst_sphinx_source_dir')
call self.log('g:syntastic_rst_sphinx_source_dir =', srcdir)
let srcdir = syntastic#util#bufVar(buf, 'rst_sphinx_source_dir')
call self.log('syntastic_rst_sphinx_source_dir =', srcdir)
if srcdir ==# ''
let config = syntastic#util#findFileInParent('conf.py', expand('%:p:h', 1))
let config = syntastic#util#findFileInParent('conf.py', fnamemodify(bufname(buf), ':p:h'))
if config ==# '' || !filereadable(config)
call self.log('conf.py file not found')
return []
@ -38,10 +39,10 @@ function! SyntaxCheckers_rst_sphinx_GetLocList() dict
let srcdir = fnamemodify(config, ':p:h')
endif
let confdir = syntastic#util#var('rst_sphinx_config_dir')
call self.log('g:syntastic_rst_sphinx_config_dir =', confdir)
let confdir = syntastic#util#bufVar(buf, 'rst_sphinx_config_dir')
call self.log('syntastic_rst_sphinx_config_dir =', confdir)
if confdir ==# ''
let config = syntastic#util#findFileInParent('conf.py', expand('%:p:h', 1))
let config = syntastic#util#findFileInParent('conf.py', fnamemodify(bufname(buf), ':p:h'))
let confdir = (config !=# '' && filereadable(config)) ? fnamemodify(config, ':p:h') : srcdir
endif

View File

@ -15,8 +15,8 @@ if exists('g:loaded_syntastic_sass_sass_checker')
endif
let g:loaded_syntastic_sass_sass_checker = 1
"sass caching for large files drastically speeds up the checking, but store it
"in a temp location otherwise sass puts .sass_cache dirs in the users project
" sass caching for large files drastically speeds up the checking, but store it
" in a temp location otherwise sass puts .sass_cache dirs in the users project
let s:sass_cache_location = syntastic#util#tmpdir()
lockvar s:sass_cache_location
@ -24,12 +24,12 @@ augroup syntastic
autocmd VimLeave * call syntastic#util#rmrf(s:sass_cache_location)
augroup END
"By default do not check partials as unknown variables are a syntax error
" By default do not check partials as unknown variables are a syntax error
if !exists('g:syntastic_sass_check_partials')
let g:syntastic_sass_check_partials = 0
endif
"use compass imports if available
" use compass imports if available
let s:imports = ''
if executable('compass')
let s:imports = '--compass'
@ -39,7 +39,8 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_sass_sass_GetLocList() dict
if !g:syntastic_sass_check_partials && expand('%:t', 1)[0] ==# '_'
let buf = bufnr('')
if !syntastic#util#bufVar(buf, 'sass_check_partials') && fnamemodify(bufname(buf), ':t')[0] ==# '_'
return []
endif

View File

@ -24,9 +24,10 @@ function! SyntaxCheckers_scala_fsc_GetLocList() dict
" fsc has some serious problems with the
" working directory changing after being started
" that's why we better pass an absolute path
let buf = bufnr('')
let makeprg = self.makeprgBuild({
\ 'args': '-Ystop-after:parser',
\ 'fname': syntastic#util#shexpand('%:p') })
\ 'fname': syntastic#util#shescape(fnamemodify(bufname(buf), ':p')) })
let errorformat =
\ '%E%f:%l: %trror: %m,' .

View File

@ -19,21 +19,23 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_sh_sh_IsAvailable() dict " {{{1
call self.log('shell =', s:GetShell())
return s:IsShellValid()
let buf = bufnr('')
call self.log('shell =', s:GetShell(buf))
return s:IsShellValid(buf)
endfunction " }}}1
function! SyntaxCheckers_sh_sh_GetLocList() dict " {{{1
if s:GetShell() ==# 'zsh'
let buf = bufnr('')
if s:GetShell(buf) ==# 'zsh'
return s:ForwardToZshChecker()
endif
if !s:IsShellValid()
if !s:IsShellValid(buf)
return []
endif
let makeprg = self.makeprgBuild({
\ 'exe': s:GetShell(),
\ 'exe': s:GetShell(buf),
\ 'args_after': '-n' })
let errorformat = '%f: line %l: %m'
@ -45,29 +47,29 @@ endfunction " }}}1
" Utilities {{{1
function! s:GetShell() " {{{2
if !exists('b:shell') || b:shell ==# ''
let b:shell = ''
let shebang = syntastic#util#parseShebang()['exe']
function! s:GetShell(buf) " {{{2
let shell = syntastic#util#getbufvar(a:buf, 'shell')
if shell ==# ''
let shebang = syntastic#util#parseShebang(a:buf)['exe']
if shebang !=# ''
if shebang[-strlen('bash'):-1] ==# 'bash'
let b:shell = 'bash'
let shell = 'bash'
elseif shebang[-strlen('zsh'):-1] ==# 'zsh'
let b:shell = 'zsh'
let shell = 'zsh'
elseif shebang[-strlen('sh'):-1] ==# 'sh'
let b:shell = 'sh'
let shell = 'sh'
endif
endif
" try to use env variable in case no shebang could be found
if b:shell ==# ''
let b:shell = fnamemodify($SHELL, ':t')
if shell ==# ''
let shell = fnamemodify($SHELL, ':t')
endif
endif
return b:shell
return shell
endfunction " }}}2
function! s:IsShellValid() " {{{2
let shell = s:GetShell()
function! s:IsShellValid(buf) " {{{2
let shell = s:GetShell(a:buf)
return shell !=# '' && executable(shell)
endfunction " }}}2

View File

@ -12,8 +12,9 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_sh_shellcheck_GetLocList() dict " {{{1
let buf = bufnr('')
let makeprg = self.makeprgBuild({
\ 'args': s:GetShell(),
\ 'args': s:GetShell(buf),
\ 'args_after': '-f gcc' })
let errorformat =
@ -38,15 +39,15 @@ endfunction " }}}1
" Utilities {{{1
function! s:GetShell() " {{{2
function! s:GetShell(buf) " {{{2
let sh = ''
if syntastic#util#parseShebang()['exe'] ==# ''
if syntastic#util#rawVar('is_kornshell', 0) || syntastic#util#rawVar('is_posix', 0)
if syntastic#util#parseShebang(a:buf)['exe'] ==# ''
if syntastic#util#bufRawVar(a:buf, 'is_kornshell', 0) || syntastic#util#bufRawVar(a:buf, 'is_posix', 0)
let sh = 'ksh'
elseif syntastic#util#rawVar('is_bash', 0)
elseif syntastic#util#bufRawVar(a:buf, 'is_bash', 0)
let sh = 'bash'
elseif syntastic#util#rawVar('is_sh', 0)
elseif syntastic#util#RawVar(a:buf, 'is_sh', 0)
let sh = 'sh'
endif
endif

View File

@ -44,19 +44,17 @@ endfunction " }}}1
" Utilities {{{1
function! s:GetValaOpts(buf, name, comment, cmd) " {{{2
let var = syntastic#util#var('vala_' . a:name)
let var = syntastic#util#bufVar(a:buf, 'vala_' . a:name)
if type(var) == type([])
let opts = map(copy(var), 'syntastic#util#shescape(v:val)')
elseif type(var) == type('')
if var !=# ''
let opts = split(var, '\s\+')
let opts = split(var, '\m\s\+')
else
let opts = []
for line in filter(getbufline(a:buf, 1, 100), 'v:val =~# ' . string('\m^//\s\+' . a:comment . ':\s*'))
call extend(opts, split( matchstr(line, '\m^//\s\+' . a:comment . ':\s*\zs.*'), '\s\+' ))
call extend(opts, split( matchstr(line, '\m^//\s\+' . a:comment . ':\s*\zs.*'), '\m\s\+' ))
endfor
call map( filter(opts, 'v:val !=# ""'), 'syntastic#util#shescape(v:val)' )
endif
else
call syntastic#log#error('syntastic_vala_' . a:name . ' must be either a list, or a string')

View File

@ -44,6 +44,8 @@ function! SyntaxCheckers_vim_vimlint_IsAvailable() dict " {{{1
endfunction " }}}1
function! SyntaxCheckers_vim_vimlint_GetLocList() dict " {{{1
let buf = bufnr('')
" EVL102: unused variable v
" EVL103: unused argument v
" EVL104: variable may not be initialized on some execution path: v
@ -67,17 +69,15 @@ function! SyntaxCheckers_vim_vimlint_GetLocList() dict " {{{1
\ 'EVL204': 3,
\ 'EVL205': 3 }
if exists('g:syntastic_vimlint_options') || exists('b:syntastic_vimlint_options')
let opts = syntastic#util#var('vimlint_options')
if type(opts) == type({})
let options = filter(copy(opts), 'v:key =~# "\\m^EVL"')
call extend(param, options, 'force')
endif
let opts = syntastic#util#bufVar(buf, 'vimlint_options')
if type(opts) == type({})
let options = filter(copy(opts), 'v:key =~# "\\m^EVL"')
call extend(param, options, 'force')
endif
call self.log('options =', param)
return vimlint#vimlint(expand('%', 1), param)
return vimlint#vimlint(bufname(buf), param)
endfunction " }}}1
" Utilities {{{1

View File

@ -18,10 +18,11 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_xquery_basex_GetLocList() dict
let buf = bufnr('')
let makeprg = self.makeprgBuild({
\ 'args_after': '-z',
\ 'fname_before': '-q',
\ 'fname': syntastic#util#shescape('inspect:module("' . escape(expand('%:p', 1), '"') . '")') })
\ 'fname': syntastic#util#shescape('inspect:module("' . escape(fnamemodify(bufname(buf), ':p'), '"') . '")') })
let errorformat =
\ '%f:%l:%c:%t:%n:%m,' .

View File

@ -29,13 +29,14 @@ function! SyntaxCheckers_yaml_yamlxs_IsAvailable() dict
" don't call executable() here, to allow things like
" let g:syntastic_perl_interpreter='/usr/bin/env perl'
silent! call syntastic#util#system(self.getExecEscaped() . ' ' . s:Modules() . ' -e ' . syntastic#util#shescape('exit(0)'))
silent! call syntastic#util#system(self.getExecEscaped() . ' ' . s:Modules(bufnr('')) . ' -e ' . syntastic#util#shescape('exit(0)'))
return v:shell_error == 0
endfunction
function! SyntaxCheckers_yaml_yamlxs_GetLocList() dict
let buf = bufnr('')
let makeprg = self.makeprgBuild({
\ 'args_before': s:Modules() . ' -e ' . syntastic#util#shescape('YAML::XS::LoadFile($ARGV[0])') })
\ 'args_before': s:Modules(buf) . ' -e ' . syntastic#util#shescape('YAML::XS::LoadFile($ARGV[0])') })
let errorformat =
\ '%EYAML::XS::Load Error: The problem:,' .
@ -51,12 +52,13 @@ function! SyntaxCheckers_yaml_yamlxs_GetLocList() dict
\ 'defaults': {'bufnr': bufnr('')} })
endfunction
function s:Modules()
if type(g:syntastic_perl_lib_path) == type('')
call syntastic#log#oneTimeWarn('variable g:syntastic_perl_lib_path should be a list')
let includes = split(g:syntastic_perl_lib_path, ',')
function s:Modules(buf)
let lib_path = syntastic#util#bufVar(a:buf, 'perl_lib_path')
if type(lib_path) == type('')
call syntastic#log#oneTimeWarn('variable syntastic_perl_lib_path should be a list')
let includes = split(lib_path, ',')
else
let includes = copy(syntastic#util#var('perl_lib_path'))
let includes = copy(lib_path)
endif
return join(map(includes, '"-I" . v:val') + ['-MYAML::XS'])
endfunction