mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-11 13:07:28 -05:00
Configure java +lsp test runner via dap-mode (#3049)
* Configure java +lsp test runner via dap-mode This configures dap-mode appropriately so the user can run tests directly from Doom. It adds two bindings as well which tries to mirror other major modes: * `SPC m t t` runs all the tests in the class at point. * `SPC m t s` runs a single test method at point. I also expanded the README with more details about configuring `+lsp`. * Add +java/run-test, document +lsp/uninstall-server * Add +java/debug-test * Fix localleader bindings When in `:init` they don't load in time on the initial Java buffer.
This commit is contained in:
@ -4,10 +4,31 @@
|
||||
(use-package! lsp-java
|
||||
:after lsp-clients
|
||||
: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")
|
||||
lsp-jt-root (concat doom-etc-dir "eclipse.jdt.ls/server/java-test/server/"))
|
||||
(setq lsp-java-workspace-dir (concat doom-etc-dir "java-workspace"))
|
||||
(add-hook! java-mode-local-vars #'lsp!)
|
||||
:config
|
||||
;; TODO keybinds
|
||||
)
|
||||
(when (featurep! :tools debugger +lsp)
|
||||
(defun +java/run-test ()
|
||||
"Runs test at point. If in a method, runs the test method, otherwise runs the entire test class."
|
||||
(interactive)
|
||||
(condition-case nil
|
||||
(dap-java-run-test-method)
|
||||
(user-error (dap-java-run-test-class))))
|
||||
|
||||
(defun +java/debug-test ()
|
||||
"Runs test at point in a debugger. If in a method, runs the test method, otherwise runs the entire test class."
|
||||
(interactive)
|
||||
(condition-case nil
|
||||
(call-interactively #'dap-java-debug-test-method)
|
||||
(user-error (call-interactively #'dap-java-debug-test-class))))
|
||||
|
||||
(map! :map java-mode-map
|
||||
:localleader
|
||||
(:prefix ("t" . "Test")
|
||||
:desc "Run test class or method" "t" #'+java/run-test
|
||||
:desc "Run all tests in class" "a" #'dap-java-run-test-class
|
||||
:desc "Debug test class or method" "d" #'+java/debug-test
|
||||
:desc "Debug all tests in class" "D" #'dap-java-debug-test-class)))
|
||||
:init
|
||||
(when (featurep! :tools debugger +lsp)
|
||||
(setq lsp-jt-root (concat lsp-java-server-install-dir "java-test/server/")
|
||||
dap-java-test-runner (concat lsp-java-server-install-dir "test-runner/junit-platform-console-standalone.jar"))))
|
||||
|
Reference in New Issue
Block a user