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 .
|
||||||
|
\ ' com.puppycrawl.tools.checkstyle.Main -c ' . g:syntastic_java_checkstyle_conf_file,
|
||||||
\ 'fname': fname,
|
\ 'fname': fname,
|
||||||
\ 'tail': '2>&1',
|
|
||||||
\ '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'})
|
||||||
|
|
||||||
|
@ -80,12 +80,6 @@ function! s:RemoveCarriageReturn(line)
|
|||||||
return substitute(a:line, '\r', '', 'g')
|
return substitute(a:line, '\r', '', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:RemoveCarriageReturns(errors)
|
|
||||||
for error in a:errors
|
|
||||||
let error['text'] = s:RemoveCarriageReturn(error['text'])
|
|
||||||
endfor
|
|
||||||
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)
|
||||||
@ -150,9 +144,15 @@ function! s:EditClasspath()
|
|||||||
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
|
||||||
@ -164,6 +164,7 @@ function! s:GetMavenClasspath()
|
|||||||
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/classes')
|
||||||
let mvn_classpath = s:AddToClasspath(mvn_classpath, 'target/test-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
|
||||||
@ -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)
|
||||||
@ -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)
|
||||||
|
@ -42,11 +42,15 @@ function! SyntaxCheckers_sass_sass_GetLocList()
|
|||||||
\ '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…
x
Reference in New Issue
Block a user