Control Bar
The control bar is disabled by default. It can be enabled by setting winbar.controls.enable
.

Options
Default options are listed below. Remeber, you donโt have to copy-paste them!
return {
winbar = {
controls = {
enabled = false,
position = "right",
buttons = {
"play",
"step_into",
"step_over",
"step_out",
"step_back",
"run_last",
"terminate",
"disconnect",
},
custom_buttons = {},
icons = {
pause = "๎ซ",
play = "๎ซ",
step_into = "๎ซ",
step_over = "๎ซ",
step_out = "๎ซ",
step_back = "๎ฎ",
run_last = "๎ฌท",
terminate = "๎ซ",
disconnect = "๎ซ",
},
},
},
}
Custom Buttons
nvim-dap-view
provides some default buttons for the control bar, but you can also add your own. To do that, you can use the controls.custom_buttons
table to declare your new button and then add it at the position you want in the buttons
list.
A custom button has 2 methods:
render
returning a string used to display the button (typically an emoji or a NerdFont glyph wrapped in an highlight group)action
a function that will be executed when the button is clicked. The function receives 3 arguments:clicks
the number of clicksbutton
the button clicked (l
,r
,m
)modifiers
a string with the modifiers pressed (c
forcontrol
,s
forshift
,a
foralt
andm
formeta
)
See the @ N
section in :help statusline
for the complete specifications of a click handler.
Example
An example adding 2 buttons:
fun
: the most basic button possible, just prints โ๐โ when clickedterm_restart
: an hybrid button that acts as a stop/restart button. If the stop button is triggered by anything else than a single left click (middle click, right click, double click or click with a modifier), it will disconnect the session instead.
return {
winbar = {
controls = {
enabled = true,
buttons = { "play", "step_into", "step_over", "step_out", "term_restart", "fun" },
custom_buttons = {
fun = {
render = function()
return "๐"
end,
action = function()
vim.print("๐")
end,
},
-- Stop/Restart button
-- Double click, middle click or click with a modifier disconnect instead of stop
term_restart = {
render = function()
local session = require("dap").session()
local group = session and "ControlTerminate" or "ControlRunLast"
local icon = session and "๏" or "๎ซ"
return "%#NvimDapView" .. group .. "#" .. icon .. "%*"
end,
action = function(clicks, button, modifiers)
local dap = require("dap")
local alt = clicks > 1 or button ~= "l" or modifiers:gsub(" ", "") ~= ""
if not dap.session() then
dap.run_last()
elseif alt then
dap.disconnect()
else
dap.terminate()
end
end,
},
},
},
},
}