From 03f0ce75f7e0a091ff85cea116661031dd7c0408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfonso=20Fernando=20=C3=81lvarez?= Date: Sun, 12 Jun 2022 18:54:08 +0100 Subject: [PATCH] go: add variable to allow selection of new dap-dlv-mode go: fixed added documentation on new variable --- layers/+lang/go/README.org | 13 ++++++++++++- layers/+lang/go/config.el | 4 ++++ layers/+lang/go/funcs.el | 15 ++++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/layers/+lang/go/README.org b/layers/+lang/go/README.org index 7f1fe932d..a3f3f9d11 100644 --- a/layers/+lang/go/README.org +++ b/layers/+lang/go/README.org @@ -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=): diff --git a/layers/+lang/go/config.el b/layers/+lang/go/config.el index 5fd5572bb..3864b1252 100644 --- a/layers/+lang/go/config.el +++ b/layers/+lang/go/config.el @@ -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) diff --git a/layers/+lang/go/funcs.el b/layers/+lang/go/funcs.el index d76abe8be..549392c25 100644 --- a/layers/+lang/go/funcs.el +++ b/layers/+lang/go/funcs.el @@ -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."