mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
@ -3,8 +3,9 @@
|
||||
|
||||
let s:classpath_sep = has('unix') ? ':' : ';'
|
||||
|
||||
let g:ale_java_javac_options = get(g:, 'ale_java_javac_options', '')
|
||||
let g:ale_java_javac_classpath = get(g:, 'ale_java_javac_classpath', '')
|
||||
call ale#Set('java_javac_executable', 'javac')
|
||||
call ale#Set('java_javac_options', '')
|
||||
call ale#Set('java_javac_classpath', '')
|
||||
|
||||
function! ale_linters#java#javac#GetImportPaths(buffer) abort
|
||||
let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
|
||||
@ -35,6 +36,10 @@ function! s:BuildClassPathOption(buffer, import_paths) abort
|
||||
\ : ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#javac#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'java_javac_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
|
||||
let l:cp_option = s:BuildClassPathOption(a:buffer, a:import_paths)
|
||||
let l:sp_option = ''
|
||||
@ -72,11 +77,13 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
|
||||
|
||||
" Create .class files in a temporary directory, which we will delete later.
|
||||
let l:class_file_directory = ale#engine#CreateDirectory(a:buffer)
|
||||
let l:executable = ale_linters#java#javac#GetExecutable(a:buffer)
|
||||
|
||||
" Always run javac from the directory the file is in, so we can resolve
|
||||
" relative paths correctly.
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . 'javac -Xlint'
|
||||
\ . ale#Escape(l:executable)
|
||||
\ . ' -Xlint'
|
||||
\ . ' ' . l:cp_option
|
||||
\ . ' ' . l:sp_option
|
||||
\ . ' -d ' . ale#Escape(l:class_file_directory)
|
||||
@ -119,7 +126,7 @@ endfunction
|
||||
|
||||
call ale#linter#Define('java', {
|
||||
\ 'name': 'javac',
|
||||
\ 'executable': 'javac',
|
||||
\ 'executable_callback': 'ale_linters#java#javac#GetExecutable',
|
||||
\ 'command_chain': [
|
||||
\ {'callback': 'ale_linters#java#javac#GetImportPaths', 'output_stream': 'stdout'},
|
||||
\ {'callback': 'ale_linters#java#javac#GetCommand', 'output_stream': 'stderr'},
|
||||
|
36
sources_non_forked/ale/ale_linters/java/pmd.vim
Normal file
36
sources_non_forked/ale/ale_linters/java/pmd.vim
Normal file
@ -0,0 +1,36 @@
|
||||
" Author: Johannes Wienke <languitar@semipol.de>
|
||||
" Description: PMD for Java files
|
||||
|
||||
function! ale_linters#java#pmd#Handle(buffer, lines) abort
|
||||
let l:pattern = '"\(\d\+\)",".\+","\(.\+\)","\(\d\+\)","\(\d\+\)","\(.\+\)","\(.\+\)","\(.\+\)"$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'type': 'W',
|
||||
\ 'lnum': l:match[4] + 0,
|
||||
\ 'text': l:match[5],
|
||||
\ 'code': l:match[6] . ' - ' . l:match[7],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#pmd#GetCommand(buffer) abort
|
||||
return 'pmd '
|
||||
\ . ale#Var(a:buffer, 'java_pmd_options')
|
||||
\ . ' -f csv'
|
||||
\ . ' -d %t'
|
||||
endfunction
|
||||
|
||||
if !exists('g:ale_java_pmd_options')
|
||||
let g:ale_java_pmd_options = '-R category/java/bestpractices.xml'
|
||||
endif
|
||||
|
||||
call ale#linter#Define('java', {
|
||||
\ 'name': 'pmd',
|
||||
\ 'executable': 'pmd',
|
||||
\ 'command_callback': 'ale_linters#java#pmd#GetCommand',
|
||||
\ 'callback': 'ale_linters#java#pmd#Handle',
|
||||
\})
|
Reference in New Issue
Block a user