[go] Revise support for multiple dap integrations

This commit is contained in:
Maxi Wolff 2022-06-17 17:26:35 +02:00
parent 03f0ce75f7
commit 07a0881324
No known key found for this signature in database
GPG key ID: 2DD07025BFDBD89A
3 changed files with 25 additions and 20 deletions

View file

@ -261,13 +261,16 @@ of packages, and Go's recursive operator is supported. In addition, you can
prefix it with =-= to exclude a package from searching.
** Debug
Currently are two ways to setup dap debugger in golang, =go-dap= (which depends
on a vscode extension for working properly) and =dap-dlv-go= a newer option that
do not depend on vscode extension [[https://emacs-lsp.github.io/dap-mode/page/configuration/#go][more info on dap-mode]].
By default =go-dap= is used, if you want to switch to =dap-dlv-go=, set the layer variable
=dap-dlv-mode= to true:
Currently there are two implementations to integrate with the dap debugger in golang,
=dap-go= (which depends on a vscode extension) which is
depreciated and =dap-dlv-go= the default choice which is self-contained.
More details about both can be found [[https://emacs-lsp.github.io/dap-mode/page/configuration/#go][here]].
By default =dap-dlv-go= is used, however it is also possible to use the legacy
intgration =dap-go= to do set the layer variable =go-dap-mode= as shown below:
#+begin_src emacs-lisp
(go :variables dap-dlv-mode t)
(go :variables go-dap-mode 'dap-go)
#+end_src
* Key bindings

View file

@ -75,6 +75,10 @@ If not set then `go-mode' is the default backend unless `lsp' layer is used."
"Go test command. Default is `go test`."
'string nil t)
(spacemacs|defc dap-dlv-mode nil
"Go dap mode, `dap-dlv-mode` is newer and doesn't depends on a vscode extension."
'boolean nil t)
(spacemacs|defc go-dap-mode 'dap-dlv-go
"Go dap mode. This variable defines which kind of dap integration will be used.
Default is `dap-dlv-mode' which is completely self-contained.
Alternatively the depreciated vscode integration can be used, to do so set this variable to `dap-go'.
Remember that the legacy integration requires vscode extensions to work properly."
'(choice (const dap-dlv-go) (const dap-go)) nil t)

View file

@ -47,22 +47,20 @@
(defun spacemacs//go-setup-dap ()
"Conditionally setup go DAP integration."
;; currently DAP is only available using LSP
(if dap-dlv-mode
(spacemacs//go-setup-dap-dlv)
(spacemacs//go-setup-dap-vscode)))
(when (eq go-backend 'lsp)
(pcase go-dap-mode
('dap-dlv-go (spacemacs//go-setup-dap-dlv))
('dap-go (spacemacs//go-setup-dap-vscode)))))
(defun spacemacs//go-setup-dap-vscode ()
"Conditionally setup go DAP integration with aold dlv (vscode) setup."
(when (eq go-backend 'lsp)
(require 'dap-go)
(dap-go-setup))
)
(require 'dap-go)
(dap-go-setup))
(defun spacemacs//go-setup-dap-dlv ()
"Conditionally setup go DAP integration with new dlv config."
;; currently DAP is only available using LSP
(when (eq go-backend 'lsp)
(require 'dap-dlv-go)))
(require 'dap-dlv-go))
(defun spacemacs//go-setup-format ()
"Conditionally setup format on save."