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:
James Ravn 2020-05-05 13:23:15 +01:00
parent 35591cfc4c
commit 72eaf530cf
No known key found for this signature in database
GPG key ID: 52C372C72159D6EE

View file

@ -1,13 +1,25 @@
;;; lang/java/+lsp.el -*- lexical-binding: t; -*-
;;;###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
:after lsp-clients
:hook (java-mode-local-vars . lsp!)
:after (lsp-clients dap-mode)
:hook (lsp-mode . java--lsp-jt-lens-mode-hook)
:preface
(setq lsp-java-server-install-dir (concat doom-etc-dir "eclipse.jdt.ls/server/")
lsp-java-workspace-dir (concat doom-etc-dir "java-workspace"))
:config
;; TODO keybinds
;; TODO treemacs integration (?)
)
lsp-java-workspace-dir (concat doom-etc-dir "java-workspace")
lsp-jt-root (concat doom-etc-dir "eclipse.jdt.ls/server/java-test/server")))