Skip to content

Commit d17a48e

Browse files
committed
Merge branch 'develop'
2 parents 61cd77e + f5ce0ce commit d17a48e

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

README.md

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ LSP java mode supports the following JDT Features:
1818
* Limited Gradle support
1919

2020
## Installation
21+
### Install [Eclipse JDT Language Server](https://projects.eclipse.org/projects/eclipse.jdt.ls)
22+
Download either [latest](http://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz) or [a specific version](http://download.eclipse.org/jdtls/snapshots/?d) of Eclipse JDT Language Server distribution to `~/.emacs.d/eclipse.jdt.ls/server/`
23+
24+
If you choose to have the server installed in a different directory, set `lsp-java-server-install-dir`.
25+
26+
On Linux/MacOS you could install/update [Eclipse JDT Language Server](https://projects.eclipse.org/projects/eclipse.jdt.ls) via running the following commands:
27+
28+
```bash
29+
rm -rf ~/.emacs.d/eclipse.jdt.ls/server/
30+
mkdir -p ~/.emacs.d/eclipse.jdt.ls/server/
31+
wget http://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz -O /tmp/jdt-latest.tar
32+
tar xf /tmp/jdt-latest.tar -C ~/.emacs.d/eclipse.jdt.ls/server/
33+
```
34+
2135
### Install LSP Java
2236
The recommended way to install LSP Java is via `package.el` - the built-in package
2337
manager in Emacs.
@@ -38,11 +52,56 @@ Then add the following lines to your `.emacs` and open a file from the any of th
3852
"/path/to/project2"
3953
...))
4054
```
55+
#### Quick start
56+
Minimal configuration with [company-lsp](https://github.com/tigersoldier/company-lsp and [lsp-ui](https://github.com/emacs-lsp/lsp-ui)). Make sure you have replaced the XXX placeholder with the list of the projects you want to import.
57+
```elisp
58+
(require 'cc-mode)
4159
42-
### Install [Eclipse JDT Language Server](https://projects.eclipse.org/projects/eclipse.jdt.ls)
43-
Download either [latest](http://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz) or [a specific version](http://download.eclipse.org/jdtls/snapshots/?d) of Eclipse JDT Language Server distribution to `~/.emacs.d/eclipse.jdt.ls/server/`
60+
(condition-case nil
61+
(require 'use-package)
62+
(file-error
63+
(require 'package)
64+
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
65+
(package-initialize)
66+
(package-refresh-contents)
67+
(package-install 'use-package)
68+
(require 'use-package)))
69+
70+
(use-package lsp-mode
71+
:ensure t
72+
:init (setq lsp-inhibit-message t
73+
lsp-eldoc-render-all nil
74+
lsp-highlight-symbol-at-point nil))
4475
45-
If you choose to have the server installed in a different directory, set `lsp-java-server-install-dir`
76+
(use-package company-lsp
77+
:after company
78+
:ensure t
79+
:config
80+
(add-hook 'java-mode-hook (lambda () (push 'company-lsp company-backends)))
81+
(setq company-lsp-enable-snippet t
82+
company-lsp-cache-candidates t)
83+
(push 'java-mode company-global-modes))
84+
85+
(use-package lsp-ui
86+
:ensure t
87+
:config
88+
(setq lsp-ui-sideline-enable t
89+
lsp-ui-sideline-show-symbol t
90+
lsp-ui-sideline-show-hover t
91+
lsp-ui-sideline-show-code-actions t
92+
lsp-ui-sideline-update-mode 'point))
93+
94+
(use-package lsp-java
95+
:ensure t
96+
:requires (lsp-ui-flycheck lsp-ui-sideline)
97+
:config
98+
(add-hook 'java-mode-hook 'lsp-java-enable)
99+
(add-hook 'java-mode-hook 'flycheck-mode)
100+
(add-hook 'java-mode-hook 'company-mode)
101+
(add-hook 'java-mode-hook (lambda () (lsp-ui-flycheck-enable t)))
102+
(add-hook 'java-mode-hook 'lsp-ui-sideline-mode)
103+
(setq lsp-java--workspace-folders (list (error "XXX Specify your projects here"))))
104+
```
46105
## Supported commands
47106
### LSP Mode commands
48107
| Command name | Description |

0 commit comments

Comments
 (0)