diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | ale_linters/java/javalsp.vim | 22 | ||||
-rw-r--r-- | autoload/ale/java.vim | 20 | ||||
-rw-r--r-- | doc/ale-java.txt | 23 | ||||
-rw-r--r-- | doc/ale.txt | 3 | ||||
-rw-r--r-- | test/command_callback/test_javalsp_command_callback.vader | 10 |
6 files changed, 78 insertions, 2 deletions
@@ -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) | | 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/) | -| 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) | 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 | diff --git a/ale_linters/java/javalsp.vim b/ale_linters/java/javalsp.vim new file mode 100644 index 00000000..f335e83c --- /dev/null +++ b/ale_linters/java/javalsp.vim @@ -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', +\}) diff --git a/autoload/ale/java.vim b/autoload/ale/java.vim new file mode 100644 index 00000000..b7fd10bd --- /dev/null +++ b/autoload/ale/java.vim @@ -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 diff --git a/doc/ale-java.txt b/doc/ale-java.txt index 4481e823..827a268c 100644 --- a/doc/ale-java.txt +++ b/doc/ale-java.txt @@ -76,4 +76,27 @@ g:ale_java_pmd_options *g:ale_java_pmd_options* =============================================================================== +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: diff --git a/doc/ale.txt b/doc/ale.txt index 8e126938..80d8b96c 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -127,6 +127,7 @@ CONTENTS *ale-contents* javac...............................|ale-java-javac| google-java-format..................|ale-java-google-java-format| pmd.................................|ale-java-pmd| + javalsp.............................|ale-java-javalsp| javascript............................|ale-javascript-options| eslint..............................|ale-javascript-eslint| 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` * HTML: `alex`!!, `HTMLHint`, `proselint`, `tidy`, `write-good` * 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` * JSON: `fixjson`, `jsonlint`, `jq`, `prettier` * Kotlin: `kotlinc`!!, `ktlint`!!, `languageserver` diff --git a/test/command_callback/test_javalsp_command_callback.vader b/test/command_callback/test_javalsp_command_callback.vader new file mode 100644 index 00000000..1fbfddfb --- /dev/null +++ b/test/command_callback/test_javalsp_command_callback.vader @@ -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') + |