summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoracio Sanson <horacio@allm.net>2019-05-08 11:46:19 +0900
committerHoracio Sanson <horacio@allm.net>2019-05-08 13:24:34 +0900
commit53db52e713ca1848e72ffaea0bff1c415cfa5cee (patch)
treeeaa6ccff9614416d2f1e923705980b1ed00fa9eb
parent63abd2dfefa96b3ee279ff7f42e4e918d5619ce6 (diff)
downloadale-53db52e713ca1848e72ffaea0bff1c415cfa5cee.zip
Improve eclipselsp jar search logic.
- Set default value to $HOME/eclipse.jdt.ls - Make JAR search regexp more specific. - Allow to set the VSCode extensions folder as ale_java_eclipselsp_path.
-rw-r--r--ale_linters/java/eclipselsp.vim23
-rw-r--r--doc/ale-java.txt14
-rw-r--r--test/command_callback/test_eclipselsp_command_callback.vader6
3 files changed, 26 insertions, 17 deletions
diff --git a/ale_linters/java/eclipselsp.vim b/ale_linters/java/eclipselsp.vim
index af9a325e..d0ea9d6c 100644
--- a/ale_linters/java/eclipselsp.vim
+++ b/ale_linters/java/eclipselsp.vim
@@ -3,7 +3,7 @@
let s:version_cache = {}
-call ale#Set('java_eclipselsp_path', 'eclipse.jdt.ls')
+call ale#Set('java_eclipselsp_path', ale#path#Simplify($HOME . '/eclipse.jdt.ls'))
call ale#Set('java_eclipselsp_executable', 'java')
function! ale_linters#java#eclipselsp#Executable(buffer) abort
@@ -16,20 +16,27 @@ endfunction
function! ale_linters#java#eclipselsp#JarPath(buffer) abort
let l:path = ale_linters#java#eclipselsp#TargetPath(a:buffer)
- let l:path = l:path . '/org.eclipse.jdt.ls.product/target/repository/plugins'
- let l:files = globpath(l:path, 'org.eclipse.equinox.launcher_*.jar', 1, 1)
+ " Search jar file within repository path when manually built using mvn
+ let l:repo_path = l:path . '/org.eclipse.jdt.ls.product/target/repository'
+ let l:files = globpath(l:repo_path, '**/plugins/org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1)
- if empty(l:files)
- return ''
+ if len(l:files) == 1
+ return l:files[0]
endif
- return l:files[0]
+ " Search jar file within VSCode extensions folder.
+ let l:files = globpath(l:path, '**/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 = ale_linters#java#eclipselsp#TargetPath(a:buffer)
- let l:path = l:path . '/org.eclipse.jdt.ls.product/target/repository'
+ let l:path = fnamemodify(ale_linters#java#eclipselsp#JarPath(a:buffer), ':p:h:h')
if has('win32')
let l:path = l:path . '/config_win'
diff --git a/doc/ale-java.txt b/doc/ale-java.txt
index 980fa338..2805c9c8 100644
--- a/doc/ale-java.txt
+++ b/doc/ale-java.txt
@@ -104,7 +104,7 @@ This variable can be changed to use a different executable for java.
===============================================================================
eclipselsp *ale-java-eclipselsp*
-To enable Java LSP linter you need to clone and build the eclipse.jdt.ls
+To enable Eclipse LSP linter you need to clone and build the eclipse.jdt.ls
language server from https://github.com/eclipse/eclipse.jdt.ls. Simply
clone the source code repo and then build the plugin:
@@ -114,21 +114,23 @@ Note: currently, the build can only run when launched with JDK 8. JDK 9 or more
recent versions can be used to run the server though.
After build completes the files required to run the language server will be
-located inside the repositoy folder `eclipse.jdt.ls`. Ensure to set
+located inside the repository folder `eclipse.jdt.ls`. Please ensure to set
|g:ale_java_eclipselsp_path| to the absolute path of that folder.
You could customize compiler options and code assists of the server.
-Under your project folder, modify the file
-`.settings/org.eclipse.jdt.core.prefs` with options presented at
+Under your project folder, modify the file `.settings/org.eclipse.jdt.core.prefs`
+with options presented at
https://help.eclipse.org/neon/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/JavaCore.html.
g:ale_java_eclipselsp_path *g:ale_java_eclipselsp_path*
*b:ale_java_eclipselsp_path*
Type: |String|
- Default: `'eclipse.jdt.ls'`
+ Default: `'$HOME/eclipse.jdt.ls'`
- Absolute path to the location of the eclipse.jdt.ls repository folder.
+ Absolute path to the location of the eclipse.jdt.ls repository folder. Or if
+ you have VSCode extension installed the absolute path to the VSCode extensions
+ folder (e.g. $HOME/.vscode/extensions in Linux).
g:ale_java_eclipselsp_executable *g:ale_java_eclipse_executable*
diff --git a/test/command_callback/test_eclipselsp_command_callback.vader b/test/command_callback/test_eclipselsp_command_callback.vader
index f6f587da..c0ad89a5 100644
--- a/test/command_callback/test_eclipselsp_command_callback.vader
+++ b/test/command_callback/test_eclipselsp_command_callback.vader
@@ -3,12 +3,12 @@ Before:
let b:ale_java_eclipselsp_path = '/home/user/eclipse.dst.ls'
call ale#test#SetFilename('dummy.java')
- let b:cfg = '/home/user/eclipse.dst.ls/org.eclipse.jdt.ls.product/target/repository/config_linux'
+ let b:cfg = '/testplugin/test/config_linux'
if has('win32')
- let b:cfg = '\home\user\eclipse.dst.ls\org.eclipse.jdt.ls.product\target\repository\config_win'
+ let b:cfg = 'C:\testplugin\test\config_win'
elseif has('macunix')
- let b:cfg = '/home/user/eclipse.dst.ls/org.eclipse.jdt.ls.product/target/repository/config_mac'
+ let b:cfg = '/testplugin/test/config_mac'
endif