Skip to content

Commit

Permalink
Merge pull request #2520 from hsanson/fix-eclipselsp-workspace-config
Browse files Browse the repository at this point in the history
Fix eclipselsp workspace config
  • Loading branch information
w0rp authored May 23, 2019
2 parents 092748c + 5a8ba75 commit 1a9b8a5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 13 deletions.
17 changes: 14 additions & 3 deletions ale_linters/java/eclipselsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,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_workspace_path', '')
call ale#Set('java_eclipselsp_executable', 'java')

function! ale_linters#java#eclipselsp#Executable(buffer) abort
Expand Down Expand Up @@ -89,6 +90,16 @@ function! ale_linters#java#eclipselsp#CommandWithVersion(buffer, version_lines,
return ale_linters#java#eclipselsp#Command(a:buffer, l:version)
endfunction

function! ale_linters#java#eclipselsp#WorkspacePath(buffer) abort
let l:wspath = ale#Var(a:buffer, 'java_eclipselsp_workspace_path')

if !empty(l:wspath)
return l:wspath
endif

return ale#path#Dirname(ale#java#FindProjectRoot(a:buffer))
endfunction

function! ale_linters#java#eclipselsp#Command(buffer, version) abort
let l:path = ale#Var(a:buffer, 'java_eclipselsp_path')

Expand All @@ -102,11 +113,11 @@ function! ale_linters#java#eclipselsp#Command(buffer, version) abort
\ '-noverify',
\ '-Xmx1G',
\ '-jar',
\ ale_linters#java#eclipselsp#JarPath(a:buffer),
\ ale#Escape(ale_linters#java#eclipselsp#JarPath(a:buffer)),
\ '-configuration',
\ ale_linters#java#eclipselsp#ConfigurationPath(a:buffer),
\ ale#Escape(ale_linters#java#eclipselsp#ConfigurationPath(a:buffer)),
\ '-data',
\ ale#java#FindProjectRoot(a:buffer)
\ ale#Escape(ale_linters#java#eclipselsp#WorkspacePath(a:buffer))
\ ]

if ale#semver#GTE(a:version, [1, 9])
Expand Down
14 changes: 13 additions & 1 deletion doc/ale-java.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ g:ale_java_eclipselsp_path *g:ale_java_eclipselsp_path*

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).
folder (e.g. $HOME/.vscode/extensions/redhat.java-0.4x.0 in Linux).


g:ale_java_eclipselsp_executable *g:ale_java_eclipse_executable*
Expand All @@ -154,6 +154,18 @@ g:ale_java_eclipselsp_config_path *g:ale_java_eclipse_config_path
non-writable directory like `/usr/share/java/jdtls`, as is the case when
installed via system package.


g:ale_java_eclipselsp_workspace_path *g:ale_java_eclipselsp_workspace_path*
*b:ale_java_eclipselsp_workspace_path*

Type: |String|
Default: `''`

If you have Eclipse installed is good idea to set this variable to the
absolute path of the Eclipse workspace. If not set this value will be set to
the parent folder of the project root.


===============================================================================
uncrustify *ale-java-uncrustify*

Expand Down
18 changes: 9 additions & 9 deletions test/command_callback/test_eclipselsp_command_callback.vader
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ Execute(The eclipselsp callback should return the correct default value):
\ '-noverify',
\ '-Xmx1G',
\ '-jar',
\ '',
\ ale#Escape(''),
\ '-configuration',
\ b:cfg,
\ ale#Escape(b:cfg),
\ '-data',
\ ''
\ ale#Escape(ale#path#Simplify(''))
\]
AssertLinter 'java', join(cmd, ' ')

Expand All @@ -79,11 +79,11 @@ Execute(The eclipselsp callback should allow custom executable):
\ '-noverify',
\ '-Xmx1G',
\ '-jar',
\ '',
\ ale#Escape(''),
\ '-configuration',
\ b:cfg,
\ ale#Escape(b:cfg),
\ '-data',
\ ''
\ ale#Escape(ale#path#Simplify(''))
\]
AssertLinter '/bin/foobar', join(cmd, ' ')

Expand All @@ -97,10 +97,10 @@ Execute(The eclipselsp callback should allow custom configuration path):
\ '-noverify',
\ '-Xmx1G',
\ '-jar',
\ '',
\ ale#Escape(''),
\ '-configuration',
\ ale#path#Simplify('/home/config'),
\ ale#Escape(ale#path#Simplify('/home/config')),
\ '-data',
\ ''
\ ale#Escape(ale#path#Simplify(''))
\]
AssertLinter 'java', join(cmd, ' ')

0 comments on commit 1a9b8a5

Please sign in to comment.