Cleanup.
This commit is contained in:
parent
cd289e45f0
commit
68cfe6513b
@ -36,6 +36,22 @@ function syntastic#postprocess#compressWhitespace(errors)
|
|||||||
return llist
|
return llist
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" remove spurious CR under Cygwin
|
||||||
|
function! syntastic#postprocess#cygwinRemoveCR(errors)
|
||||||
|
if has('win32unix')
|
||||||
|
let llist = []
|
||||||
|
|
||||||
|
for e in a:errors
|
||||||
|
let e['text'] = substitute(e['text'], '\r', '', 'g')
|
||||||
|
call add(llist, e)
|
||||||
|
endfor
|
||||||
|
else
|
||||||
|
let llist = a:errors
|
||||||
|
endif
|
||||||
|
|
||||||
|
return llist
|
||||||
|
endfunction
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
let &cpo = s:save_cpo
|
||||||
unlet s:save_cpo
|
unlet s:save_cpo
|
||||||
" vim: set et sts=4 sw=4:
|
" vim: set et sts=4 sw=4:
|
||||||
|
@ -27,47 +27,28 @@ function! SyntaxCheckers_java_checkstyle_IsAvailable()
|
|||||||
return executable('java')
|
return executable('java')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CygwinPath(path)
|
|
||||||
return substitute(system("cygpath -m ".a:path), '\%x00', '', 'g')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:RemoveCarriageReturn(line)
|
|
||||||
return substitute(a:line, '\r', '', 'g')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:RemoveCarriageReturns(errors)
|
|
||||||
for error in a:errors
|
|
||||||
let error['text'] = s:RemoveCarriageReturn(error['text'])
|
|
||||||
endfor
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! SyntaxCheckers_java_checkstyle_GetLocList()
|
function! SyntaxCheckers_java_checkstyle_GetLocList()
|
||||||
|
|
||||||
let fname = fnameescape(expand ( '%:p:h' ) . '/' . expand ( '%:t' ))
|
let fname = fnameescape( expand('%:p:h') . '/' . expand('%:t') )
|
||||||
|
|
||||||
if has('win32unix')
|
if has('win32unix')
|
||||||
let fname = s:CygwinPath(fname)
|
let fname = substitute(system('cygpath -m ' . fname), '\%x00', '', 'g')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let makeprg = syntastic#makeprg#build({
|
let makeprg = syntastic#makeprg#build({
|
||||||
\ 'exe': 'java',
|
\ 'exe': 'java',
|
||||||
\ 'args': '-cp ' . g:syntastic_java_checkstyle_classpath . ' com.puppycrawl.tools.checkstyle.Main -c ' . g:syntastic_java_checkstyle_conf_file,
|
\ 'args': '-cp ' . g:syntastic_java_checkstyle_classpath .
|
||||||
\ 'fname': fname,
|
\ ' com.puppycrawl.tools.checkstyle.Main -c ' . g:syntastic_java_checkstyle_conf_file,
|
||||||
\ 'tail': '2>&1',
|
\ 'fname': fname,
|
||||||
\ 'subchecker': 'checkstyle' })
|
\ 'subchecker': 'checkstyle' })
|
||||||
|
|
||||||
" check style format
|
" check style format
|
||||||
let errorformat = '%f:%l:%c:\ %m,%f:%l:\ %m'
|
let errorformat = '%f:%l:%c:\ %m,%f:%l:\ %m'
|
||||||
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
|
||||||
|
|
||||||
if has('win32unix')
|
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'postprocess': ['cygwinRemoveCR'] })
|
||||||
call s:RemoveCarriageReturns(errors)
|
|
||||||
endif
|
|
||||||
|
|
||||||
return errors
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||||
\ 'filetype': 'java',
|
\ 'filetype': 'java',
|
||||||
\ 'name': 'checkstyle'})
|
\ 'name': 'checkstyle'})
|
||||||
|
|
||||||
|
@ -37,15 +37,15 @@ if !exists("g:syntastic_java_javac_delete_output")
|
|||||||
let g:syntastic_java_javac_delete_output = 1
|
let g:syntastic_java_javac_delete_output = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! s:CygwinPath(path)
|
function! s:CygwinPath(path)
|
||||||
return substitute(system("cygpath -m ".a:path), '\%x00', '', 'g')
|
return substitute(system("cygpath -m ".a:path), '\%x00', '', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
if !exists("g:syntastic_java_javac_temp_dir")
|
if !exists("g:syntastic_java_javac_temp_dir")
|
||||||
if has('win32') || has('win64')
|
if has('win32') || has('win64')
|
||||||
let g:syntastic_java_javac_temp_dir = $TEMP."\\vim-syntastic-javac"
|
let g:syntastic_java_javac_temp_dir = $TEMP."\\vim-syntastic-javac"
|
||||||
elseif has('win32unix')
|
elseif has('win32unix')
|
||||||
let g:syntastic_java_javac_temp_dir=s:CygwinPath('/tmp/vim-syntastic-javac')
|
let g:syntastic_java_javac_temp_dir = s:CygwinPath('/tmp/vim-syntastic-javac')
|
||||||
else
|
else
|
||||||
let g:syntastic_java_javac_temp_dir = '/tmp/vim-syntastic-javac'
|
let g:syntastic_java_javac_temp_dir = '/tmp/vim-syntastic-javac'
|
||||||
endif
|
endif
|
||||||
@ -77,22 +77,16 @@ if !exists("g:syntastic_java_javac_maven_pom_classpath")
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
function! s:RemoveCarriageReturn(line)
|
function! s:RemoveCarriageReturn(line)
|
||||||
return substitute(a:line, '\r', '', 'g')
|
return substitute(a:line, '\r', '', 'g')
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:RemoveCarriageReturns(errors)
|
|
||||||
for error in a:errors
|
|
||||||
let error['text'] = s:RemoveCarriageReturn(error['text'])
|
|
||||||
endfor
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" recursively remove directory and all it's sub-directories
|
" recursively remove directory and all it's sub-directories
|
||||||
function! s:RemoveDir(dir)
|
function! s:RemoveDir(dir)
|
||||||
if isdirectory(a:dir)
|
if isdirectory(a:dir)
|
||||||
for f in split(globpath(a:dir,'*'),"\n")
|
for f in split(globpath(a:dir, '*'), "\n")
|
||||||
call s:RemoveDir(f)
|
call s:RemoveDir(f)
|
||||||
endfor
|
endfor
|
||||||
silent! call system('rmdir '.a:dir)
|
silent! call system('rmdir ' . a:dir)
|
||||||
else
|
else
|
||||||
silent! call delete(a:dir)
|
silent! call delete(a:dir)
|
||||||
endif
|
endif
|
||||||
@ -119,7 +113,7 @@ function! s:LoadClasspathFromConfigFile()
|
|||||||
let lines = readfile(g:syntastic_java_javac_config_file)
|
let lines = readfile(g:syntastic_java_javac_config_file)
|
||||||
for l in lines
|
for l in lines
|
||||||
if l != ''
|
if l != ''
|
||||||
let path .= l."\n"
|
let path .= l . "\n"
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
return path
|
return path
|
||||||
@ -130,14 +124,14 @@ endfunction
|
|||||||
|
|
||||||
function! s:SaveClasspath()
|
function! s:SaveClasspath()
|
||||||
let path = ''
|
let path = ''
|
||||||
let lines = getline(1,line('$'))
|
let lines = getline(1, line('$'))
|
||||||
" save classpath to config file
|
" save classpath to config file
|
||||||
if g:syntastic_java_javac_config_file_enabled
|
if g:syntastic_java_javac_config_file_enabled
|
||||||
call writefile(lines,g:syntastic_java_javac_config_file)
|
call writefile(lines,g:syntastic_java_javac_config_file)
|
||||||
endif
|
endif
|
||||||
for l in lines
|
for l in lines
|
||||||
if l != ''
|
if l != ''
|
||||||
let path .= l."\n"
|
let path .= l . "\n"
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
let g:syntastic_java_javac_classpath = path
|
let g:syntastic_java_javac_classpath = path
|
||||||
@ -149,10 +143,16 @@ function! s:EditClasspath()
|
|||||||
let winnr = bufwinnr('^' . command . '$')
|
let winnr = bufwinnr('^' . command . '$')
|
||||||
if winnr < 0
|
if winnr < 0
|
||||||
let pathlist = split(g:syntastic_java_javac_classpath,"\n")
|
let pathlist = split(g:syntastic_java_javac_classpath,"\n")
|
||||||
execute (len(pathlist)+5) . 'sp ' . fnameescape(command)
|
execute (len(pathlist) + 5) . 'sp ' . fnameescape(command)
|
||||||
au BufWriteCmd <buffer> call s:SaveClasspath() | bwipeout
|
|
||||||
|
augroup syntastic
|
||||||
|
autocmd BufWriteCmd <buffer> call s:SaveClasspath() | bwipeout
|
||||||
|
augroup END
|
||||||
|
|
||||||
setlocal buftype=acwrite bufhidden=wipe nobuflisted noswapfile nowrap number
|
setlocal buftype=acwrite bufhidden=wipe nobuflisted noswapfile nowrap number
|
||||||
for p in pathlist | call append(line('$')-1,p) | endfor
|
for p in pathlist
|
||||||
|
call append(line('$') - 1, p)
|
||||||
|
endfor
|
||||||
else
|
else
|
||||||
execute winnr . 'wincmd w'
|
execute winnr . 'wincmd w'
|
||||||
endif
|
endif
|
||||||
@ -162,8 +162,9 @@ command! SyntasticJavacEditClasspath call s:EditClasspath()
|
|||||||
function! s:GetMavenClasspath()
|
function! s:GetMavenClasspath()
|
||||||
if filereadable('pom.xml')
|
if filereadable('pom.xml')
|
||||||
if g:syntastic_java_javac_maven_pom_ftime != getftime('pom.xml') || g:syntastic_java_javac_maven_pom_cwd != getcwd()
|
if g:syntastic_java_javac_maven_pom_ftime != getftime('pom.xml') || g:syntastic_java_javac_maven_pom_cwd != getcwd()
|
||||||
let mvn_classpath_output = split(system(g:syntastic_java_maven_executable.' dependency:build-classpath'),"\n")
|
let mvn_classpath_output = split(system(g:syntastic_java_maven_executable . ' dependency:build-classpath'), "\n")
|
||||||
let class_path_next = 0
|
let class_path_next = 0
|
||||||
|
|
||||||
for line in mvn_classpath_output
|
for line in mvn_classpath_output
|
||||||
if class_path_next == 1
|
if class_path_next == 1
|
||||||
let mvn_classpath = s:RemoveCarriageReturn(line)
|
let mvn_classpath = s:RemoveCarriageReturn(line)
|
||||||
@ -173,8 +174,10 @@ function! s:GetMavenClasspath()
|
|||||||
let class_path_next = 1
|
let class_path_next = 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
let mvn_classpath = s:AddToClasspath(mvn_classpath,'target/classes')
|
|
||||||
let mvn_classpath = s:AddToClasspath(mvn_classpath,'target/test-classes')
|
let mvn_classpath = s:AddToClasspath(mvn_classpath, 'target/classes')
|
||||||
|
let mvn_classpath = s:AddToClasspath(mvn_classpath, 'target/test-classes')
|
||||||
|
|
||||||
let g:syntastic_java_javac_maven_pom_cwd = getcwd()
|
let g:syntastic_java_javac_maven_pom_cwd = getcwd()
|
||||||
let g:syntastic_java_javac_maven_pom_ftime = getftime('pom.xml')
|
let g:syntastic_java_javac_maven_pom_ftime = getftime('pom.xml')
|
||||||
let g:syntastic_java_javac_maven_pom_classpath = mvn_classpath
|
let g:syntastic_java_javac_maven_pom_classpath = mvn_classpath
|
||||||
@ -190,28 +193,28 @@ endfunction
|
|||||||
|
|
||||||
function! s:MavenOutputDirectory()
|
function! s:MavenOutputDirectory()
|
||||||
if filereadable('pom.xml')
|
if filereadable('pom.xml')
|
||||||
let output_dir = getcwd()
|
let output_dir = getcwd()
|
||||||
if match(expand( '%:p:h' ), "src.main.java") >= 0
|
if match(expand( '%:p:h' ), "src.main.java") >= 0
|
||||||
let output_dir .= '/target/classes'
|
let output_dir .= '/target/classes'
|
||||||
endif
|
endif
|
||||||
if match(expand( '%:p:h' ), "src.test.java") >= 0
|
if match(expand( '%:p:h' ), "src.test.java") >= 0
|
||||||
let output_dir .= '/target/test-classes'
|
let output_dir .= '/target/test-classes'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has('win32unix')
|
if has('win32unix')
|
||||||
let output_dir=s:CygwinPath(output_dir)
|
let output_dir=s:CygwinPath(output_dir)
|
||||||
endif
|
endif
|
||||||
return output_dir
|
return output_dir
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SyntaxCheckers_java_javac_GetLocList()
|
function! SyntaxCheckers_java_javac_GetLocList()
|
||||||
|
|
||||||
let javac_opts = g:syntastic_java_javac_options
|
let javac_opts = g:syntastic_java_javac_options
|
||||||
|
|
||||||
if g:syntastic_java_javac_delete_output
|
if g:syntastic_java_javac_delete_output
|
||||||
let output_dir = g:syntastic_java_javac_temp_dir
|
let output_dir = g:syntastic_java_javac_temp_dir
|
||||||
let javac_opts .= ' -d ' .output_dir
|
let javac_opts .= ' -d ' . output_dir
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" load classpath from config file
|
" load classpath from config file
|
||||||
@ -234,7 +237,9 @@ function! SyntaxCheckers_java_javac_GetLocList()
|
|||||||
endtry
|
endtry
|
||||||
if type(ps) == type([])
|
if type(ps) == type([])
|
||||||
for p in ps
|
for p in ps
|
||||||
if p != '' | let javac_classpath = s:AddToClasspath(javac_classpath,p) | endif
|
if p != ''
|
||||||
|
let javac_classpath = s:AddToClasspath(javac_classpath,p)
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
else
|
else
|
||||||
let javac_classpath = s:AddToClasspath(javac_classpath,ps)
|
let javac_classpath = s:AddToClasspath(javac_classpath,ps)
|
||||||
@ -243,10 +248,10 @@ function! SyntaxCheckers_java_javac_GetLocList()
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
if g:syntastic_java_javac_autoload_maven_classpath
|
if g:syntastic_java_javac_autoload_maven_classpath
|
||||||
if !g:syntastic_java_javac_delete_output
|
if !g:syntastic_java_javac_delete_output
|
||||||
let maven_output_dir = s:MavenOutputDirectory()
|
let maven_output_dir = s:MavenOutputDirectory()
|
||||||
let javac_opts .= ' -d ' . maven_output_dir
|
let javac_opts .= ' -d ' . maven_output_dir
|
||||||
endif
|
endif
|
||||||
let maven_classpath = s:GetMavenClasspath()
|
let maven_classpath = s:GetMavenClasspath()
|
||||||
let javac_classpath = s:AddToClasspath(javac_classpath,maven_classpath)
|
let javac_classpath = s:AddToClasspath(javac_classpath,maven_classpath)
|
||||||
endif
|
endif
|
||||||
@ -257,23 +262,23 @@ function! SyntaxCheckers_java_javac_GetLocList()
|
|||||||
|
|
||||||
" path seperator
|
" path seperator
|
||||||
if has('win32') || has('win32unix') || has('win64')
|
if has('win32') || has('win32unix') || has('win64')
|
||||||
let sep = "\\"
|
let sep = "\\"
|
||||||
else
|
else
|
||||||
let sep = '/'
|
let sep = '/'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let fname = fnameescape(expand ( '%:p:h' ) . sep . expand ( '%:t' ))
|
let fname = fnameescape(expand ( '%:p:h' ) . sep . expand ( '%:t' ))
|
||||||
|
|
||||||
if has('win32unix')
|
if has('win32unix')
|
||||||
let fname = s:CygwinPath(fname)
|
let fname = s:CygwinPath(fname)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let makeprg = syntastic#makeprg#build({
|
let makeprg = syntastic#makeprg#build({
|
||||||
\ 'exe': g:syntastic_java_javac_executable,
|
\ 'exe': g:syntastic_java_javac_executable,
|
||||||
\ 'args': javac_opts,
|
\ 'args': javac_opts,
|
||||||
\ 'fname': fname,
|
\ 'fname': fname,
|
||||||
\ 'tail': '2>&1',
|
\ 'tail': '2>&1',
|
||||||
\ 'subchecker': 'javac' })
|
\ 'subchecker': 'javac' })
|
||||||
|
|
||||||
" unashamedly stolen from *errorformat-javac* (quickfix.txt) and modified to include error types
|
" unashamedly stolen from *errorformat-javac* (quickfix.txt) and modified to include error types
|
||||||
let errorformat = '%E%f:%l:\ error:\ %m,%W%f:%l:\ warning:\ %m,%A%f:%l:\ %m,%+Z%p^,%+C%.%#,%-G%.%#'
|
let errorformat = '%E%f:%l:\ error:\ %m,%W%f:%l:\ warning:\ %m,%A%f:%l:\ %m,%+Z%p^,%+C%.%#,%-G%.%#'
|
||||||
@ -281,11 +286,7 @@ function! SyntaxCheckers_java_javac_GetLocList()
|
|||||||
if g:syntastic_java_javac_delete_output
|
if g:syntastic_java_javac_delete_output
|
||||||
silent! call mkdir(output_dir,'p')
|
silent! call mkdir(output_dir,'p')
|
||||||
endif
|
endif
|
||||||
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'postprocess': ['cygwinRemoveCR'] })
|
||||||
|
|
||||||
if has('win32unix')
|
|
||||||
call s:RemoveCarriageReturns(errors)
|
|
||||||
endif
|
|
||||||
|
|
||||||
if g:syntastic_java_javac_delete_output
|
if g:syntastic_java_javac_delete_output
|
||||||
call s:RemoveDir(output_dir)
|
call s:RemoveDir(output_dir)
|
||||||
|
@ -39,14 +39,18 @@ function! SyntaxCheckers_sass_sass_GetLocList()
|
|||||||
return []
|
return []
|
||||||
end
|
end
|
||||||
let makeprg = syntastic#makeprg#build({
|
let makeprg = syntastic#makeprg#build({
|
||||||
\ 'exe': 'sass',
|
\ 'exe': 'sass',
|
||||||
\ 'args': '--cache-location ' . s:sass_cache_location . ' ' . s:imports . ' --check',
|
\ 'args': '--cache-location ' . s:sass_cache_location . ' ' . s:imports . ' --check',
|
||||||
\ 'subchecker': 'sass' })
|
\ 'subchecker': 'sass' })
|
||||||
let errorformat = '%ESyntax %trror:%m,%C on line %l of %f,%Z%.%#'
|
let errorformat =
|
||||||
let errorformat .= ',%Wwarning on line %l:,%Z%m,Syntax %trror on line %l: %m'
|
\ '%ESyntax %trror:%m,' .
|
||||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
\ '%C on line %l of %f,' .
|
||||||
|
\ '%Z%.%#,' .
|
||||||
|
\ '%Wwarning on line %l:,' .
|
||||||
|
\ '%Z%m,' .
|
||||||
|
\ 'Syntax %trror on line %l: %m'
|
||||||
|
|
||||||
return loclist
|
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||||
|
Loading…
Reference in New Issue
Block a user