Skip to content

Commit

Permalink
feat: add TIL neovim debugging buffer open
Browse files Browse the repository at this point in the history
  • Loading branch information
hmajid2301 committed Dec 17, 2023
1 parent 1d176ac commit 29a0364
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: "TIL: How to Use Open Buffers When Debugging With Neovim's DAP Plugin"
date: 2023-12-24
canonicalURL: https://haseebmajid.dev/posts/2023-12-24-til-how-to-use-open-buffers-when-debugging-with-neovim-dap-plugin
tags:
- DAP
- neovim
- nvim
series:
- TIL
---

**TIL: How to Use Open Buffers When Debugging With Neovim's DAP Plugin**

I had an issue that whilst debugging my Golang tests in Neovim, the buffer I was focusing on would always change to
the breakpoint. Even when the buffer was open and visible already, say I had the code with the breakpoint on the left
buffer and the tests I was starting the debugger from on the right buffer.

You can see the example belows:

![Example Setup](images/example.png)

When I start the DAP debugger on the right hand side, by using it to debug the nearest tests, the buffer will change
to the breakpointed line. However I want it to use the open buffer on the left because it is already open.

To do this we need to update our Neovim options: `vim.o.switchbuf = "useopen,uselast"`. This will now behave as we
want. Note `uselast`, here is the default value for this option. You can read more about by typing `:help 'switchbuf`.

That's it! We can now debugger our code and keep the layout we have.

0 comments on commit 29a0364

Please sign in to comment.