Add vscode-java-language-server linter
This commit is contained in:
parent
707b539969
commit
3afff5a24c
28
ale_linters/java/javalsp.vim
Normal file
28
ale_linters/java/javalsp.vim
Normal file
@ -0,0 +1,28 @@
|
||||
" Author: Horacio Sanson <https://github.com/hsanson>
|
||||
" Description: Support for the Java language server https://github.com/georgewfraser/vscode-javac
|
||||
|
||||
call ale#Set('java_javalsp_jar', 'javacs.jar')
|
||||
|
||||
function! ale_linters#java#javalsp#Executable(buffer) abort
|
||||
let l:jar = ale#VarFunc('java_javalsp_jar')(a:buffer)
|
||||
|
||||
if filereadable(l:jar)
|
||||
return 'java'
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#javalsp#Command(buffer) abort
|
||||
let l:jar = ale#VarFunc('java_javalsp_jar')(a:buffer)
|
||||
return 'exec java -cp ' . l:jar . ' -Xverify:none org.javacs.Main'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('java', {
|
||||
\ 'name': 'javalsp',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable_callback': 'ale_linters#java#javalsp#Executable',
|
||||
\ 'command_callback': 'ale_linters#java#javalsp#Command',
|
||||
\ 'language': 'java',
|
||||
\ 'project_root_callback': 'ale#java#FindProjectRoot',
|
||||
\})
|
20
autoload/ale/java.vim
Normal file
20
autoload/ale/java.vim
Normal file
@ -0,0 +1,20 @@
|
||||
" Author: Horacio Sanson https://github.com/hsanson
|
||||
" Description: Functions for integrating with Java tools
|
||||
|
||||
" Find the nearest dir contining a gradle or pom file and asume it
|
||||
" the root of a java app.
|
||||
function! ale#java#FindProjectRoot(buffer) abort
|
||||
let l:gradle_root = ale#gradle#FindProjectRoot(a:buffer)
|
||||
|
||||
if !empty(l:gradle_root)
|
||||
return l:gradle_root
|
||||
endif
|
||||
|
||||
let l:maven_pom_file = ale#path#FindNearestFile(a:buffer, 'pom.xml')
|
||||
|
||||
if !empty(l:maven_pom_file)
|
||||
return fnamemodify(l:maven_pom_file, ':h')
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
@ -75,5 +75,28 @@ g:ale_java_pmd_options *g:ale_java_pmd_options*
|
||||
and -d. They are added automatically.
|
||||
|
||||
|
||||
===============================================================================
|
||||
javalsp *ale-java-javalsp*
|
||||
|
||||
To enable Java LSP linter you need to download and build the vscode-javac
|
||||
language server from https://github.com/georgewfraser/vscode-javac. Simply
|
||||
download the source code and then build the plugin using maven:
|
||||
|
||||
mvn package
|
||||
|
||||
This generates a out/fat-jar.jar file that contains the language server. To
|
||||
let ALE use this language server you need to set the g:ale_java_javalsp_jar
|
||||
variable to the absolute path of this jar file.
|
||||
|
||||
g:ale_java_javalsp_jar *g:ale_java_javalsp_jar*
|
||||
*b:ale_java_javalsp_jar*
|
||||
|
||||
Type: String
|
||||
Default: 'fat-jar.jar
|
||||
|
||||
Path to the location of the vscode-javac language server plugin.
|
||||
and -d. They are added automatically.
|
||||
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||
|
Loading…
Reference in New Issue
Block a user