diff options
author | Grim Kriegor <grimkriegor@krutt.org> | 2019-05-21 21:13:06 +0100 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2019-05-21 21:13:06 +0100 |
commit | 0427ee84b4af77be84cbb005c26dc2142305fb73 (patch) | |
tree | b7e78622533a6f2969374722256b2b447e97e5cf | |
parent | f6ae056d02e82143f26db49b642d2f6d82d12cde (diff) | |
download | ale-0427ee84b4af77be84cbb005c26dc2142305fb73.zip |
Allow running eclipselsp as installed by system package on GNU/Linux (#2523)
* Search eclipselsp jar and config files within system package path
* Allow setting an alternate eclipselsp configuration directory
* Add test for ale_java_eclipselsp_config_path
-rw-r--r-- | ale_linters/java/eclipselsp.vim | 13 | ||||
-rw-r--r-- | doc/ale-java.txt | 13 | ||||
-rw-r--r-- | test/command_callback/test_eclipselsp_command_callback.vader | 17 |
3 files changed, 43 insertions, 0 deletions
diff --git a/ale_linters/java/eclipselsp.vim b/ale_linters/java/eclipselsp.vim index d0ea9d6c..c0b476a3 100644 --- a/ale_linters/java/eclipselsp.vim +++ b/ale_linters/java/eclipselsp.vim @@ -4,6 +4,7 @@ let s:version_cache = {} call ale#Set('java_eclipselsp_path', ale#path#Simplify($HOME . '/eclipse.jdt.ls')) +call ale#Set('java_eclipselsp_config_path', '') call ale#Set('java_eclipselsp_executable', 'java') function! ale_linters#java#eclipselsp#Executable(buffer) abort @@ -32,11 +33,23 @@ function! ale_linters#java#eclipselsp#JarPath(buffer) abort return l:files[0] endif + " Search jar file within system package path + let l:files = globpath('/usr/share/java/jdtls/plugins', 'org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) + + if len(l:files) == 1 + return l:files[0] + endif + return '' endfunction function! ale_linters#java#eclipselsp#ConfigurationPath(buffer) abort let l:path = fnamemodify(ale_linters#java#eclipselsp#JarPath(a:buffer), ':p:h:h') + let l:config_path = ale#Var(a:buffer, 'java_eclipselsp_config_path') + + if !empty(l:config_path) + return ale#path#Simplify(l:config_path) + endif if has('win32') let l:path = l:path . '/config_win' diff --git a/doc/ale-java.txt b/doc/ale-java.txt index 2805c9c8..b61a90a0 100644 --- a/doc/ale-java.txt +++ b/doc/ale-java.txt @@ -141,6 +141,19 @@ g:ale_java_eclipselsp_executable *g:ale_java_eclipse_executable* This variable can be set to change the executable path used for java. +g:ale_java_eclipselsp_config_path *g:ale_java_eclipse_config_path* + *b:ale_java_eclipse_config_path* + Type: |String| + Default: `''` + + Set this variable to change the configuration directory path used by + eclipselsp (e.g. `$HOME/.jdtls` in Linux). + By default ALE will attempt to use the configuration within the installation + directory. + This setting is particularly useful when eclipselsp is installed in a + non-writable directory like `/usr/share/java/jdtls`, as is the case when + installed via system package. + =============================================================================== uncrustify *ale-java-uncrustify* diff --git a/test/command_callback/test_eclipselsp_command_callback.vader b/test/command_callback/test_eclipselsp_command_callback.vader index c0ad89a5..881eb8c1 100644 --- a/test/command_callback/test_eclipselsp_command_callback.vader +++ b/test/command_callback/test_eclipselsp_command_callback.vader @@ -85,3 +85,20 @@ Execute(The eclipselsp callback should allow custom executable): \] AssertLinter '/bin/foobar', join(cmd, ' ') +Execute(The eclipselsp callback should allow custom configuration path): + let b:ale_java_eclipselsp_config_path='/home/config' + let cmd = [ ale#Escape('java'), + \ '-Declipse.application=org.eclipse.jdt.ls.core.id1', + \ '-Dosgi.bundles.defaultStartLevel=4', + \ '-Declipse.product=org.eclipse.jdt.ls.core.product', + \ '-Dlog.level=ALL', + \ '-noverify', + \ '-Xmx1G', + \ '-jar', + \ '', + \ '-configuration', + \ b:ale_java_eclipselsp_config_path, + \ '-data', + \ '' + \] + AssertLinter 'java', join(cmd, ' ') |