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:
parent
f6ae056d02
commit
0427ee84b4
@ -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'
|
||||
|
@ -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*
|
||||
|
||||
|
@ -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, ' ')
|
||||
|
Loading…
Reference in New Issue
Block a user