[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

@ -91,7 +91,7 @@ prepared you can simply run below command to install:
**** Debugger **** Debugger
Using the =dap= layer you'll get access to a graphical debugger integration. Using the =dap= layer you'll get access to a graphical debugger integration.
To do so add the layer =dap= to your dotfile. For a complete list of key bindings To do so add the layer =dap= to your dotfile. For a complete list of key bindings
see the [[https://github.com/syl20bnr/spacemacs/tree/develop/layers/%2Btools/dap#key-bindings][dap layer description]]. See [[#debug][debugger configuration]] for options. see the [[https://github.com/syl20bnr/spacemacs/tree/develop/layers/%2Btools/dap#key-bindings][dap layer description]]. See [[#debug][debugger configuration]] for options.
*** go-mode (deprecated) *** go-mode (deprecated)
This was the old elisp based go backend. Since the introduction of This was the old elisp based go backend. Since the introduction of
@ -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. prefix it with =-= to exclude a package from searching.
** Debug ** Debug
Currently are two ways to setup dap debugger in golang, =go-dap= (which depends Currently there are two implementations to integrate with the dap debugger in golang,
on a vscode extension for working properly) and =dap-dlv-go= a newer option that =dap-go= (which depends on a vscode extension) which is
do not depend on vscode extension [[https://emacs-lsp.github.io/dap-mode/page/configuration/#go][more info on dap-mode]]. depreciated and =dap-dlv-go= the default choice which is self-contained.
By default =go-dap= is used, if you want to switch to =dap-dlv-go=, set the layer variable More details about both can be found [[https://emacs-lsp.github.io/dap-mode/page/configuration/#go][here]].
=dap-dlv-mode= to true:
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 #+begin_src emacs-lisp
(go :variables dap-dlv-mode t) (go :variables go-dap-mode 'dap-go)
#+end_src #+end_src
* Key bindings * 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`." "Go test command. Default is `go test`."
'string nil t) 'string nil t)
(spacemacs|defc dap-dlv-mode nil (spacemacs|defc go-dap-mode 'dap-dlv-go
"Go dap mode, `dap-dlv-mode` is newer and doesn't depends on a vscode extension." "Go dap mode. This variable defines which kind of dap integration will be used.
'boolean nil t)
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 () (defun spacemacs//go-setup-dap ()
"Conditionally setup go DAP integration." "Conditionally setup go DAP integration."
;; currently DAP is only available using LSP ;; currently DAP is only available using LSP
(if dap-dlv-mode (when (eq go-backend 'lsp)
(spacemacs//go-setup-dap-dlv) (pcase go-dap-mode
(spacemacs//go-setup-dap-vscode))) ('dap-dlv-go (spacemacs//go-setup-dap-dlv))
('dap-go (spacemacs//go-setup-dap-vscode)))))
(defun spacemacs//go-setup-dap-vscode () (defun spacemacs//go-setup-dap-vscode ()
"Conditionally setup go DAP integration with aold dlv (vscode) setup." "Conditionally setup go DAP integration with aold dlv (vscode) setup."
(when (eq go-backend 'lsp) (require 'dap-go)
(require 'dap-go) (dap-go-setup))
(dap-go-setup))
)
(defun spacemacs//go-setup-dap-dlv () (defun spacemacs//go-setup-dap-dlv ()
"Conditionally setup go DAP integration with new dlv config." "Conditionally setup go DAP integration with new dlv config."
;; currently DAP is only available using LSP (require 'dap-dlv-go))
(when (eq go-backend 'lsp)
(require 'dap-dlv-go)))
(defun spacemacs//go-setup-format () (defun spacemacs//go-setup-format ()
"Conditionally setup format on save." "Conditionally setup format on save."