debugmaster.nvim is a neovim plugin that provides two things:
- DEBUG mode (like "Insert" or "Normal" mode, but built for debugging)
- Debugger UI assembled from nvim-dap native widgets (so this plugin also serves as a dap-ui alternative)
debugmaster.mp4
The goals of this plugin:
- establish a DEBUG mode for neovim
- Imagine how a debugging workflow should look in a modal editor
- Provide UI suitable for modal editor - so you can always stay in the flow, focusing only on important things without any distractions
- Neovim >= 0.10 (>= 0.11 is recommended)
- nvim-dap
The plugin is completely usable, but still under development. Breaking changes are possible—follow commit notices.
Using lazy.nvim plugin manager:
return {
{ "rcarriga/nvim-dap-ui", enabled = false },
{
"miroshQa/debugmaster.nvim",
-- osv is needed if you want to debug neovim lua code. Also can be used
-- as a way to quickly test-drive the plugin without configuring debug adapters
dependencies = { "mfussenegger/nvim-dap", "jbyuki/one-small-step-for-vimkind", },
config = function()
local dm = require("debugmaster")
-- make sure you don't have any other keymaps that starts with "<leader>d" to avoid delay
-- Alternative keybindings to "<leader>d" could be: "<leader>m", "<leader>;"
vim.keymap.set({ "n", "v" }, "<leader>d", dm.mode.toggle, { nowait = true })
-- If you want to disable debug mode in addition to leader+d using the Escape key:
-- vim.keymap.set("n", "<Esc>", dm.mode.disable)
-- This might be unwanted if you already use Esc for ":noh"
vim.keymap.set("t", "<C-\\>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
dm.plugins.osv_integration.enabled = true -- needed if you want to debug neovim lua code
local dap = require("dap")
-- Configure your debug adapters here
-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation
end
}
}
NOTE: Don't mix this plugin with dap-ui!
- Configure your debug adapters using nvim-dap.
- Press
<leader>d
to toggle debug mode. - Press
H
in debug mode to view available commands. - Toggle the side panel with
u
. - Toggle float mode with
U
if the side panel has too little space to display content. - Set/toggle breakpoints with
t
and start debugging withc
. - Navigate through debug sessions using debug mode keymaps (
o
- step over,m
- step into,q
- step out,r
- run to cursor). You can view all of them in the Help section by pressingH
.
You can find explanations regarding the choice of these keymaps and a dap-view-like UI here
local dm = require("debugmaster")
-- keymaps changing example
dm.keys.get("x").key = "y" -- remap x key in debug mode to y
-- changing some plugin options (see 1. note)
dm.plugins.cursor_hl.enabled = false
dm.plugins.ui_auto_toggle.enabled = false
-- Changing debug mode cursor hl
-- Debug mode cursor color controlled by "dCursor" highlight group
-- so to change it you can use the following code
vim.api.nvim_set_hl(0, "dCursor", {bg = "#FF2C2C"})
-- make sure to call this after you do vim.cmd("colorscheme x")
-- otherwise this highlight group could be cleaned by your colorscheme
- You are assumed to discover other dm options either using lua language server autocompletion or inspecting the correponding file
Recipes for how to configure debugmaster for reverse debugging of c++, c, and rust, how to display debug mode in your status line, starting debug neovim lua code in two keypresses and more can be found here.
- Inspired by nvim-dap-view
- nvim-dap