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
This commit is contained in:
Grim Kriegor 2019-05-21 21:13:06 +01:00 committed by w0rp
parent f6ae056d02
commit 0427ee84b4
3 changed files with 43 additions and 0 deletions

View File

@ -4,6 +4,7 @@
let s:version_cache = {} let s:version_cache = {}
call ale#Set('java_eclipselsp_path', ale#path#Simplify($HOME . '/eclipse.jdt.ls')) 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') call ale#Set('java_eclipselsp_executable', 'java')
function! ale_linters#java#eclipselsp#Executable(buffer) abort function! ale_linters#java#eclipselsp#Executable(buffer) abort
@ -32,11 +33,23 @@ function! ale_linters#java#eclipselsp#JarPath(buffer) abort
return l:files[0] return l:files[0]
endif 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 '' return ''
endfunction endfunction
function! ale_linters#java#eclipselsp#ConfigurationPath(buffer) abort function! ale_linters#java#eclipselsp#ConfigurationPath(buffer) abort
let l:path = fnamemodify(ale_linters#java#eclipselsp#JarPath(a:buffer), ':p:h:h') 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') if has('win32')
let l:path = l:path . '/config_win' let l:path = l:path . '/config_win'

View File

@ -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. 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* uncrustify *ale-java-uncrustify*

View File

@ -85,3 +85,20 @@ Execute(The eclipselsp callback should allow custom executable):
\] \]
AssertLinter '/bin/foobar', join(cmd, ' ') 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, ' ')