Make some improvements to java +lsp
This is a first pass at making `+lsp` more functional: * Fix lsp not starting automatically when opening java-mode buffers. Placing it in the lsp-java hook does not work. * Enable the code lens for test classes. * Add a keybinding/function to easily update the eclipse LSP server. * Add a keybinding to bring up the lsp-jt-browser (the treemacs based browser that lists all the project tests). * Fix root path for lsp-jt. There are still a lot of rough edges here, and I don't think it's quite usable yet, mostly due to issues around the java test mode (lsp-jt). The other functionality all seems to work well though.
This commit is contained in:
parent
35591cfc4c
commit
72eaf530cf
1 changed files with 19 additions and 7 deletions
|
@ -1,13 +1,25 @@
|
||||||
;;; lang/java/+lsp.el -*- lexical-binding: t; -*-
|
;;; lang/java/+lsp.el -*- lexical-binding: t; -*-
|
||||||
;;;###if (featurep! +lsp)
|
;;;###if (featurep! +lsp)
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +java/update-lsp-server ()
|
||||||
|
(interactive)
|
||||||
|
(lsp--install-server-internal (gethash 'jdtls lsp-clients) t))
|
||||||
|
|
||||||
|
(add-hook! java-mode-local-vars #'lsp!)
|
||||||
|
(map! :map java-mode-map
|
||||||
|
:localleader
|
||||||
|
:desc "Update the Eclipse LSP server" "U" #'+java/update-lsp-server
|
||||||
|
:desc "Open the test browser" "T" #'lsp-jt-browser)
|
||||||
|
|
||||||
|
;; TODO: This fails on the first java buffer opened - complains about the LSP server not having executeCode capabilities.
|
||||||
|
(defun java--lsp-jt-lens-mode-hook ()
|
||||||
|
(when (derived-mode-p 'java-mode) (lsp-jt-lens-mode)))
|
||||||
|
|
||||||
(use-package! lsp-java
|
(use-package! lsp-java
|
||||||
:after lsp-clients
|
:after (lsp-clients dap-mode)
|
||||||
:hook (java-mode-local-vars . lsp!)
|
:hook (lsp-mode . java--lsp-jt-lens-mode-hook)
|
||||||
:preface
|
:preface
|
||||||
(setq lsp-java-server-install-dir (concat doom-etc-dir "eclipse.jdt.ls/server/")
|
(setq lsp-java-server-install-dir (concat doom-etc-dir "eclipse.jdt.ls/server/")
|
||||||
lsp-java-workspace-dir (concat doom-etc-dir "java-workspace"))
|
lsp-java-workspace-dir (concat doom-etc-dir "java-workspace")
|
||||||
:config
|
lsp-jt-root (concat doom-etc-dir "eclipse.jdt.ls/server/java-test/server")))
|
||||||
;; TODO keybinds
|
|
||||||
;; TODO treemacs integration (?)
|
|
||||||
)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue