1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| (use-package eglot
:ensure t
:config
(defconst my/jdtls-project-root (expand-file-name (concat user-emacs-directory ".cache/lsp/eclipse.jdt.ls/")))
(defconst my/jdtls-jar-file-pattern "^org\.eclipse\.equinox\.launcher_[1-9].*\.jar$")
(defun my/jdtls-find-executable-jar-file (dir file-pattern)
(car (directory-files-recursively dir file-pattern)))
(defun my/eclipse-jdt-contact (interactive)
(let ((cp (getenv "CLASSPATH"))
(path_seprator ":"))
(if (eq system-type 'windows-nt)
(setq path_seprator ";"))
(setenv "CLASSPATH" (concat cp path_seprator (my/jdtls-find-executable-jar-file my/jdtls-project-root my/jdtls-jar-file-pattern)))
(message (getenv "CLASSPATH"))
(unwind-protect
(eglot--eclipse-jdt-contact nil)
(setenv "CLASSPATH" cp))))
(setcdr (assq 'java-mode eglot-server-programs) #'my/eclipse-jdt-contact)
(add-hook 'java-mode-hook 'eglot-ensure)
)
|