summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.org25
-rw-r--r--emacs/custom/fcuny-navigation.el8
-rw-r--r--emacs/custom/fcuny-prog.el35
-rw-r--r--emacs/custom/fcuny-ui.el4
4 files changed, 71 insertions, 1 deletions
diff --git a/README.org b/README.org
index c43b4aa..2d782e2 100644
--- a/README.org
+++ b/README.org
@@ -4,6 +4,31 @@
 - keep it simple
 - configurations work the same way, everywhere
 * emacs
+** go
+*** compile
+You can compile a go binary using =M-x compile= inside a go buffer.
+*** debugging
+We need to install =dlv= first:
+#+begin_src sh
+go install github.com/go-delve/delve/cmd/dlv@latest
+#+end_src
+
+For =dap-mode= you also need to install =nodejs=. On arch you do this with
+#+begin_src sh
+sudo pacman -Syu nodejs
+#+end_src
+
+Then from emacs =M-x dap-go-set= to install the dependencies.
+
+It's unclear as to why =node= is still in the picture since it looks like =dlv= seems to support =dap= directly (see [[https://github.com/go-delve/delve/issues/1515][delve/issues/1515]]).
+
+To debug a program, you can set breakpoints where you need with =M-x dap-breakpoint-add=. To start the debugger hit =M-x dap-debug=.
+
+If the program you debug needs argument, call =M-x dap-debug-edit-template=. Add the argument(s) you need to the program and evaluate the buffer (=C-c C-e=). Next time you call the debugger, the argument(s) will be passed to the program. You can also set environment variables if you need.
+
+The binding =C-c d= will bring an hydra menu for debugging.
+
+The REPL is not brought on by default when starting a debugging session, but =M-x dap-ui-repl= will start a REPL (the position is controlled by the variable =dap-ui-buffer-configurations=).
 * Linux
 ** installed packages
 Under arch linux, you can run the following to get the list of installed packages:
diff --git a/emacs/custom/fcuny-navigation.el b/emacs/custom/fcuny-navigation.el
index de17080..1a58666 100644
--- a/emacs/custom/fcuny-navigation.el
+++ b/emacs/custom/fcuny-navigation.el
@@ -152,4 +152,12 @@
   :config
   (which-key-mode))
 
+;; treemacs is being pulled by lsp/dap mode, so let's be explicit
+;; about getting it installed, and ensure that it writes its own data
+;; in our var directory.
+(use-package treemacs
+  :ensure t
+  :custom
+  (treemacs-persist-file (expand-file-name "treemacs-persist" fcuny/path-emacs-var)))
+
 (provide 'fcuny-navigation)
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)
diff --git a/emacs/custom/fcuny-ui.el b/emacs/custom/fcuny-ui.el
index 693c0a9..c350088 100644
--- a/emacs/custom/fcuny-ui.el
+++ b/emacs/custom/fcuny-ui.el
@@ -84,4 +84,8 @@
   (setq uniquify-buffer-name-style 'forward)
   (setq uniquify-separator "/"))
 
+;; required for dap-mode and dap-ui-mode
+(use-package posframe
+  :ensure t)
+
 (provide 'fcuny-ui)