summaryrefslogtreecommitdiff
path: root/ale_linters/java
diff options
context:
space:
mode:
authorHoracio Sanson <horacio@allm.net>2019-06-19 11:38:23 +0900
committerHoracio Sanson <horacio@allm.net>2019-06-19 11:38:23 +0900
commit40bf6e6b5c2cd8e5e23141254fa9f8bee5e6cd84 (patch)
tree42c404afca7e2818bd3b5ce3cbf33cea9d34404c /ale_linters/java
parent1c71da5624fc46107cda4852add08fe34385dfd9 (diff)
downloadale-40bf6e6b5c2cd8e5e23141254fa9f8bee5e6cd84.zip
Add support for javalsp configuration options.
This MR adds a new configuration variable `g:ale_java_javalsp_config` that allows to configure external dependencies and class paths to the language server. The variable accepts a dictionary similar to the one supported by the [vscode/settings.json](https://github.com/georgewfraser/java-language-server#settings) file. Deprecates: #2561
Diffstat (limited to 'ale_linters/java')
-rw-r--r--ale_linters/java/javalsp.vim14
1 files changed, 14 insertions, 0 deletions
diff --git a/ale_linters/java/javalsp.vim b/ale_linters/java/javalsp.vim
index f56675d6..baf584c8 100644
--- a/ale_linters/java/javalsp.vim
+++ b/ale_linters/java/javalsp.vim
@@ -2,11 +2,24 @@
" Description: Support for the Java language server https://github.com/georgewfraser/vscode-javac
call ale#Set('java_javalsp_executable', '')
+call ale#Set('java_javalsp_config', {})
function! ale_linters#java#javalsp#Executable(buffer) abort
return ale#Var(a:buffer, 'java_javalsp_executable')
endfunction
+function! ale_linters#java#javalsp#Config(buffer) abort
+ let l:defaults = { 'java': { 'classPath': [], 'externalDependencies': [] } }
+ let l:config = ale#Var(a:buffer, 'java_javalsp_config')
+
+ " Ensure the config dictionary contains both classPath and
+ " externalDependencies keys to avoid a NPE crash on Java Language Server.
+ call extend(l:config, l:defaults, 'keep')
+ call extend(l:config['java'], l:defaults['java'], 'keep')
+
+ return l:config
+endfunction
+
function! ale_linters#java#javalsp#Command(buffer) abort
let l:executable = ale_linters#java#javalsp#Executable(a:buffer)
@@ -38,4 +51,5 @@ call ale#linter#Define('java', {
\ 'command': function('ale_linters#java#javalsp#Command'),
\ 'language': 'java',
\ 'project_root': function('ale#java#FindProjectRoot'),
+\ 'lsp_config': function('ale_linters#java#javalsp#Config')
\})