From 3778c840afecec735758fbd217dd3021c5337233 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sun, 4 Apr 2021 12:59:58 -0700 Subject: emacs: configure dap-mode and compile-mode Debug Adapter Protocol (DAP) is wire protocol to communicate between a client and debug server. This is similar to LSP, but for debuggers. This initial configuration focuses on enabling the mode and setting the layout for the various buffers (in this case I want the different buffers on the right screen and keep the main part focused on the code). I also disable some widget to use the debugger with hydra. There's still a number of things that are incomplete when it comes to integrate DAP and delve (the go debugger): there's no way to call functions, to have access to the variables, etc. But this is a good start though, to debug simple problems without relying on print statement. This also update the configuration for =go= so that =M-x compile=, when editing a go file, by default will use =go build=. This is not what I always need / want but this is a good default. --- emacs/custom/fcuny-prog.el | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'emacs/custom/fcuny-prog.el') diff --git a/emacs/custom/fcuny-prog.el b/emacs/custom/fcuny-prog.el index 3cc97d9..1ca50ca 100644 --- a/emacs/custom/fcuny-prog.el +++ b/emacs/custom/fcuny-prog.el @@ -55,6 +55,33 @@ :ensure t :commands lsp-ivy-workspace-symbol) +(use-package dap-mode + :ensure t + :after (lsp-mode) + :bind ("C-c d" . dap-hydra) + :init + (use-package dap-go) + :custom + (dap-utils-extension-path (expand-file-name ".extension" fcuny/path-emacs-var)) + (dap-breakpoints-file (expand-file-name "dap-breakpoints" fcuny/path-emacs-var)) + (dap-ui-controls-mode nil) + (dap-ui-buffer-configurations + `((,dap-ui--locals-buffer . ((side . right) (slot . 1) (window-width . 0.2))) + (,dap-ui--expressions-buffer . ((side . right) (slot . 2) (window-width . 0.2))) + (,dap-ui--sessions-buffer . ((side . right) (slot . 3) (window-width . 0.2))) + (,dap-ui--breakpoints-buffer . ((side . right) (slot . 4) (window-width . 0.2))) + (,dap-ui--repl-buffer . ((side . bottom) (slot . 1) (window-width . 0.4))) + (,dap-ui--debug-window-buffer . ((side . bottom) (slot . 2) (window-height . 0.2))))) + :config + (dap-mode t) + (dap-ui-mode t) + (dap-tooltip-mode t) + (tooltip-mode t)) + +;; I don't want to have the icons as an overlay in the UI, I prefer to +;; use the bindings or the mapping provided by hydra +(eval-after-load 'lsp-mode '(advice-add 'dap-ui--update-controls :override #'ignore)) + (use-package sh-script :mode ("bashrc" . sh-mode) :hook (after-save . executable-make-buffer-file-executable-if-script-p) @@ -76,7 +103,8 @@ (use-package go-mode :ensure t :hook ((before-save . lsp-format-buffer) - (before-save . lsp-organize-imports)) + (before-save . lsp-organize-imports) + (go-mode . fcuny/setup-go-mode-compile)) :config (when (memq window-system '(mac ns)) (exec-path-from-shell-copy-env "GOPATH")) @@ -96,4 +124,9 @@ :bind (:map puppet-mode-map ("C-c |" . puppet-align-block))) +(defun fcuny/setup-go-mode-compile () + (if (not (string-match "go" compile-command)) + (set (make-local-variable 'compile-command) + "go build -v"))) + (provide 'fcuny-prog) -- cgit 1.4.1