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'})
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ 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
|
||||||
@ -80,19 +80,13 @@ 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)
|
||||||
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
|
||||||
@ -211,7 +214,7 @@ function! SyntaxCheckers_java_javac_GetLocList()
|
|||||||
|
|
||||||
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)
|
||||||
@ -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…
Reference in New Issue
Block a user