feat(lang): enable debugging current test in go-mode via dap-mode

Adds a function and keybinding to lookup name of current test via
a gotest.el helper function, and runs dap-mode with relevant config to
debug the specific test name found.
This commit is contained in:
2021-01-04 00:20:09 +00:00
parent e7366a4fbd
commit 672d6d819c

View File

@@ -89,10 +89,6 @@
(lsp-deferred)))
(use-package dap-go
:straight dap-mode
:after (go-mode dap-mode))
(use-package go-dlv
:defer t)
@@ -111,6 +107,27 @@
:custom
(go-test-verbose t))
(use-package dap-go
:straight dap-mode
:after (go-mode gotest dap-mode)
:bind (:map dap-mode-map
("C-c , d" . siren-dap-go-debug-current-test))
:init
(defun siren-dap-go-debug-current-test ()
(interactive)
(let ((name (go-test--get-current-test)))
(dap-debug
(list :type "go"
:request "launch"
:name (concat "Go: Debug " name " test")
:mode "auto"
:program "${workspaceFolder}"
:buildFlags nil
:args (concat "-test.run ^" name "$")
:env nil
:envFile nil)))))
(use-package go-gen-test
:defer t
:after (go-mode)