mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 13:34:46 +08:00
Merge pull request #1849 from hsanson/1848-add-support-for-java-lsp
Add vscode-java-language-server linter
This commit is contained in:
@@ -132,7 +132,7 @@ formatting.
|
|||||||
| Haskell | [brittany](https://github.com/lspitzner/brittany), [ghc](https://www.haskell.org/ghc/), [cabal-ghc](https://www.haskell.org/cabal/), [stylish-haskell](https://github.com/jaspervdj/stylish-haskell), [stack-ghc](https://haskellstack.org/), [stack-build](https://haskellstack.org/) !!, [ghc-mod](https://github.com/DanielG/ghc-mod), [stack-ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools), [hfmt](https://github.com/danstiner/hfmt), [hie](https://github.com/haskell/haskell-ide-engine) |
|
| Haskell | [brittany](https://github.com/lspitzner/brittany), [ghc](https://www.haskell.org/ghc/), [cabal-ghc](https://www.haskell.org/cabal/), [stylish-haskell](https://github.com/jaspervdj/stylish-haskell), [stack-ghc](https://haskellstack.org/), [stack-build](https://haskellstack.org/) !!, [ghc-mod](https://github.com/DanielG/ghc-mod), [stack-ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools), [hfmt](https://github.com/danstiner/hfmt), [hie](https://github.com/haskell/haskell-ide-engine) |
|
||||||
| HTML | [alex](https://github.com/wooorm/alex) !!, [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/), [write-good](https://github.com/btford/write-good) |
|
| HTML | [alex](https://github.com/wooorm/alex) !!, [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/), [write-good](https://github.com/btford/write-good) |
|
||||||
| Idris | [idris](http://www.idris-lang.org/) |
|
| Idris | [idris](http://www.idris-lang.org/) |
|
||||||
| Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html), [google-java-format](https://github.com/google/google-java-format), [PMD](https://pmd.github.io/) |
|
| Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html), [google-java-format](https://github.com/google/google-java-format), [PMD](https://pmd.github.io/), [javalsp](https://github.com/georgewfraser/vscode-javac) |
|
||||||
| JavaScript | [eslint](http://eslint.org/), [flow](https://flowtype.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [prettier](https://github.com/prettier/prettier), [prettier-eslint](https://github.com/prettier/prettier-eslint-cli), [prettier-standard](https://github.com/sheerun/prettier-standard), [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo)
|
| JavaScript | [eslint](http://eslint.org/), [flow](https://flowtype.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [prettier](https://github.com/prettier/prettier), [prettier-eslint](https://github.com/prettier/prettier-eslint-cli), [prettier-standard](https://github.com/sheerun/prettier-standard), [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo)
|
||||||
| JSON | [fixjson](https://github.com/rhysd/fixjson), [jsonlint](http://zaa.ch/jsonlint/), [jq](https://stedolan.github.io/jq/), [prettier](https://github.com/prettier/prettier) |
|
| JSON | [fixjson](https://github.com/rhysd/fixjson), [jsonlint](http://zaa.ch/jsonlint/), [jq](https://stedolan.github.io/jq/), [prettier](https://github.com/prettier/prettier) |
|
||||||
| Kotlin | [kotlinc](https://kotlinlang.org) !!, [ktlint](https://ktlint.github.io) !!, [languageserver](https://github.com/fwcd/KotlinLanguageServer) see `:help ale-integration-kotlin` for configuration instructions |
|
| Kotlin | [kotlinc](https://kotlinlang.org) !!, [ktlint](https://ktlint.github.io) !!, [languageserver](https://github.com/fwcd/KotlinLanguageServer) see `:help ale-integration-kotlin` for configuration instructions |
|
||||||
|
|||||||
22
ale_linters/java/javalsp.vim
Normal file
22
ale_linters/java/javalsp.vim
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
" 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
|
||||||
|
return 'java'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#java#javalsp#Command(buffer) abort
|
||||||
|
let l:jar = ale#Var(a:buffer, 'java_javalsp_jar')
|
||||||
|
return ale#Escape('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.
|
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:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ CONTENTS *ale-contents*
|
|||||||
javac...............................|ale-java-javac|
|
javac...............................|ale-java-javac|
|
||||||
google-java-format..................|ale-java-google-java-format|
|
google-java-format..................|ale-java-google-java-format|
|
||||||
pmd.................................|ale-java-pmd|
|
pmd.................................|ale-java-pmd|
|
||||||
|
javalsp.............................|ale-java-javalsp|
|
||||||
javascript............................|ale-javascript-options|
|
javascript............................|ale-javascript-options|
|
||||||
eslint..............................|ale-javascript-eslint|
|
eslint..............................|ale-javascript-eslint|
|
||||||
flow................................|ale-javascript-flow|
|
flow................................|ale-javascript-flow|
|
||||||
@@ -388,7 +389,7 @@ Notes:
|
|||||||
* Haskell: `brittany`, `ghc`, `cabal-ghc`, `stylish-haskell`, `stack-ghc`, `stack-build`!!, `ghc-mod`, `stack-ghc-mod`, `hlint`, `hdevtools`, `hfmt`, `hie`
|
* Haskell: `brittany`, `ghc`, `cabal-ghc`, `stylish-haskell`, `stack-ghc`, `stack-build`!!, `ghc-mod`, `stack-ghc-mod`, `hlint`, `hdevtools`, `hfmt`, `hie`
|
||||||
* HTML: `alex`!!, `HTMLHint`, `proselint`, `tidy`, `write-good`
|
* HTML: `alex`!!, `HTMLHint`, `proselint`, `tidy`, `write-good`
|
||||||
* Idris: `idris`
|
* Idris: `idris`
|
||||||
* Java: `checkstyle`, `javac`, `google-java-format`, `PMD`
|
* Java: `checkstyle`, `javac`, `google-java-format`, `PMD`, `javalsp`
|
||||||
* JavaScript: `eslint`, `flow`, `jscs`, `jshint`, `prettier`, `prettier-eslint`, `prettier-standard`, `standard`, `xo`
|
* JavaScript: `eslint`, `flow`, `jscs`, `jshint`, `prettier`, `prettier-eslint`, `prettier-standard`, `standard`, `xo`
|
||||||
* JSON: `fixjson`, `jsonlint`, `jq`, `prettier`
|
* JSON: `fixjson`, `jsonlint`, `jq`, `prettier`
|
||||||
* Kotlin: `kotlinc`!!, `ktlint`!!, `languageserver`
|
* Kotlin: `kotlinc`!!, `ktlint`!!, `languageserver`
|
||||||
|
|||||||
10
test/command_callback/test_javalsp_command_callback.vader
Normal file
10
test/command_callback/test_javalsp_command_callback.vader
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
Before:
|
||||||
|
call ale#assert#SetUpLinterTest('java', 'javalsp')
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
|
Execute(The javalsp callback should return the correct default value):
|
||||||
|
AssertLinter 'java', ale#Escape('java -cp javacs.jar -Xverify:none org.javacs.Main')
|
||||||
|
|
||||||
Reference in New Issue
Block a user