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. --- README.org | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'README.org') 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: -- cgit 1.4.1