go: add variable to allow selection of new dap-dlv-mode

go: fixed added documentation on new variable
This commit is contained in:
Alfonso Fernando Álvarez 2022-06-12 18:54:08 +01:00 committed by Maxi Wolff
parent 44894c7132
commit 03f0ce75f7
No known key found for this signature in database
GPG Key ID: 2DD07025BFDBD89A
3 changed files with 30 additions and 2 deletions

View File

@ -23,6 +23,7 @@
- [[#tests][Tests]]
- [[#coverage][Coverage]]
- [[#guru][Guru]]
- [[#debug][Debug]]
- [[#key-bindings][Key bindings]]
- [[#go-commands-start-with-m][Go commands (start with =m=):]]
- [[#go-guru][Go Guru]]
@ -90,7 +91,7 @@ prepared you can simply run below command to install:
**** Debugger
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
see the [[https://github.com/syl20bnr/spacemacs/tree/develop/layers/%2Btools/dap#key-bindings][dap layer description]].
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)
This was the old elisp based go backend. Since the introduction of
@ -259,6 +260,16 @@ will need to set the scope with ~SPC m f o~. The scope is a comma separated set
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:
#+begin_src emacs-lisp
(go :variables dap-dlv-mode t)
#+end_src
* Key bindings
** Go commands (start with =m=):

View File

@ -74,3 +74,7 @@ If not set then `go-mode' is the default backend unless `lsp' layer is used."
(spacemacs|defc go-test-command "go test"
"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)

View File

@ -47,9 +47,22 @@
(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)))
(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)))
(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)))
(defun spacemacs//go-setup-format ()
"Conditionally setup format on save."