Skip to content

Commit

Permalink
Configure using global options
Browse files Browse the repository at this point in the history
  • Loading branch information
lgranie committed Mar 12, 2019
1 parent cb7b1ad commit 18e0962
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@ Plug 'prabirshrestha/vim-lsp'
Plug 'lgranie/vim-lsp-java'
```

### Edit jdtls file
### Configure vim-lsp-java

Edit your .vimrc file and configure like :

" vim-lsp-java
let g:vim_lsp_java = {
\ 'eclipse_jdt_ls' : {
\ 'repository': expand('~/opt/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository'),
\ 'version': '1.5.300.v20190213-1655',
\ 'config': 'config_linux',
\ 'workspace': '/mnt/c/workspace',
\ },
\ }

To launch the server, this plugin use a script you need to edit to your personnal installation
~/.vim/bundle/vim-lsp-java/jdtls

## Usage

Expand Down
13 changes: 8 additions & 5 deletions jdtls
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#!/bin/bash

JDTLS_REPOSITORY=/home/lgranie/opt/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository
JDTLS_REPOSITORY=$1
JDTLS_VERSION=$2
JDTLS_CONFIG=$3
JDTLS_WORKSPACE=$4

java -Declipse.application=org.eclipse.jdt.ls.core.id1 \
-Dosgi.bundles.defaultStartLevel=4 \
-Declipse.product=org.eclipse.jdt.ls.core.product \
-Dlog.level=ALL \
-Dlog.level=ERROR \
-noverify \
-Xmx1G \
-jar $JDTLS_REPOSITORY/plugins/org.eclipse.equinox.launcher_1.5.300.v20190213-1655.jar \
-configuration $JDTLS_REPOSITORY/config_linux \
-data /mnt/c/workspace-poc \
-jar $JDTLS_REPOSITORY/plugins/org.eclipse.equinox.launcher_$2.jar \
-configuration $JDTLS_REPOSITORY/$JDTLS_CONFIG \
-data $JDTLS_WORKSPACE \
--add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED

4 changes: 2 additions & 2 deletions plugin/lsp-java.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
let s:vim_lsp_java = get(g:, 'vim_lsp_java', [])
let g:vim_lsp_java = get(g:, 'vim_lsp_java', [])

if isdirectory(vim_lsp_java.eclipse_jdt_ls.repository)
au User lsp_setup call lsp#register_server({
\ 'name': 'java support using eclipse.jdt.ls',
\ 'cmd': {server_info->[&shell, &shellcmdflag, expand('~/.vim/bundle/vim-lsp-java/jdtls')]},
\ 'cmd': {server_info->[&shell, &shellcmdflag, expand('~/.vim/bundle/vim-lsp-java/jdtls'), g:vim_lsp_java.eclipse_jdt_ls.repository, g:vim_lsp_java.eclipse_jdt_ls.version, g:vim_lsp_java.eclipse_jdt_ls.config, g:vim_lsp_java.eclipse_jdt_ls.workspace]},
\ 'root_uri':{server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), 'pom.xml'))},
\ 'whitelist': ['java'],
\ })
Expand Down

0 comments on commit 18e0962

Please sign in to comment.