more more more
This commit is contained in:
@ -4,16 +4,19 @@ local keymap_restore = {}
|
||||
--- make the default hover binding work for nvim-dap instead of lsp
|
||||
local function set_hover_bind()
|
||||
for _, buf in pairs(vim.api.nvim_list_bufs()) do
|
||||
local keymaps = vim.api.nvim_buf_get_keymap(buf, 'n')
|
||||
local keymaps = vim.api.nvim_buf_get_keymap(buf, "n")
|
||||
for _, keymap in pairs(keymaps) do
|
||||
if keymap.lhs == "K" then
|
||||
table.insert(keymap_restore, keymap)
|
||||
vim.api.nvim_buf_del_keymap(buf, 'n', 'K')
|
||||
vim.api.nvim_buf_del_keymap(buf, "n", "K")
|
||||
end
|
||||
end
|
||||
end
|
||||
vim.keymap.set('n', 'K', require("dap.ui.widgets").hover,
|
||||
{ silent = true })
|
||||
map("n", "K", function()
|
||||
require("dap.ui.widgets").hover(nil, {
|
||||
border = vim.g.border_style
|
||||
})
|
||||
end, { silent = true })
|
||||
end
|
||||
|
||||
--- revert the hover bind back to whatever it was
|
||||
@ -30,59 +33,110 @@ local function unset_hover_bind()
|
||||
keymap_restore = {}
|
||||
end
|
||||
|
||||
return { "mfussenegger/nvim-dap",
|
||||
requires = {
|
||||
"mason-org/mason.nvim",
|
||||
"nvim-telescope/telescope.nvim"
|
||||
},
|
||||
disable = not vim.fn.has("nvim-0.9.5"),
|
||||
branch = "0.10.0",
|
||||
function()
|
||||
local dap = require("dap")
|
||||
return {
|
||||
{ "mfussenegger/nvim-dap",
|
||||
reqs = {
|
||||
"mason-org/mason.nvim",
|
||||
"nvim-telescope/telescope.nvim"
|
||||
},
|
||||
deps = "theHamsta/nvim-dap-virtual-text",
|
||||
disable = not vim.fn.has("nvim-0.9.5"),
|
||||
branch = "0.10.0",
|
||||
lazy = function(load)
|
||||
load:keymap("n", "<leader>ec")
|
||||
load:keymap("n", "<leader>el")
|
||||
load:keymap("n", "<leader>et")
|
||||
load:keymap("n", "<leader>eb")
|
||||
load:keymap("n", "<leader>e]")
|
||||
load:keymap("n", "<leader>e[")
|
||||
load:keymap("n", "<leader>er")
|
||||
load:keymap("n", "<leader>eR")
|
||||
end,
|
||||
load = function()
|
||||
local dap = require("dap")
|
||||
|
||||
-- define codelldb
|
||||
dap.adapters.codelldb = {
|
||||
type = "executable",
|
||||
command = "codelldb"
|
||||
}
|
||||
|
||||
-- define the c configuration for codelldb
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = "Launch file",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd()..'/', 'file')
|
||||
end,
|
||||
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = false
|
||||
-- define codelldb
|
||||
dap.adapters.codelldb = {
|
||||
type = "executable",
|
||||
command = "codelldb"
|
||||
}
|
||||
}
|
||||
|
||||
-- and define them for cpp, zig, and rust
|
||||
dap.configurations.cpp = dap.configurations.c
|
||||
dap.configurations.zig = dap.configurations.c
|
||||
dap.configurations.rust = dap.configurations.c
|
||||
-- define the c configuration for codelldb
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = "Launch file",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd().."/", "file")
|
||||
end,
|
||||
|
||||
-- keybinds
|
||||
map("n", "<leader>ec", dap.continue, { desc = "dap continue" })
|
||||
map("n", "<leader>el", dap.run_last, { desc = "dap run last" })
|
||||
map("n", "<leader>et", function()
|
||||
dap.terminate()
|
||||
unset_hover_bind()
|
||||
end, { desc = "dap terminate " })
|
||||
map("n", "<leader>eb", require("dap.breakpoints").toggle, {
|
||||
desc = "dap toggle breakpoint"
|
||||
})
|
||||
map("n", "<leader>e]", dap.step_over, { desc = "dap step over" })
|
||||
map("n", "<leader>e[", dap.step_back, { desc = "dap step back" })
|
||||
map("n", "<leader>er", dap.repl.toggle, { desc = "dap repl toggle" })
|
||||
map("n", "<leader>eR", dap.restart, { desc = "dap restart" })
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = false
|
||||
}
|
||||
}
|
||||
|
||||
-- events
|
||||
dap.listeners.after['event_initialized']['me'] = set_hover_bind
|
||||
dap.listeners.after['event_terminated']['me'] = unset_hover_bind
|
||||
end
|
||||
-- and define them for cpp, zig, and rust
|
||||
dap.configurations.cpp = dap.configurations.c
|
||||
dap.configurations.zig = dap.configurations.c
|
||||
dap.configurations.rust = dap.configurations.c
|
||||
|
||||
-- keybinds
|
||||
map("n", "<leader>ec", dap.continue, { desc = "dap continue" })
|
||||
map("n", "<leader>el", dap.run_last, { desc = "dap run last" })
|
||||
map("n", "<leader>et", function()
|
||||
dap.terminate()
|
||||
unset_hover_bind()
|
||||
end, { desc = "dap terminate " })
|
||||
map("n", "<leader>eb", require("dap.breakpoints").toggle, {
|
||||
desc = "dap toggle breakpoint"
|
||||
})
|
||||
map("n", "<leader>e]", dap.step_over, { desc = "dap step over" })
|
||||
map("n", "<leader>e[", dap.step_back, { desc = "dap step back" })
|
||||
map("n", "<leader>er", dap.repl.toggle, { desc = "dap repl toggle" })
|
||||
map("n", "<leader>eR", dap.restart, { desc = "dap restart" })
|
||||
|
||||
-- events
|
||||
dap.listeners.after["event_initialized"]["me"] = set_hover_bind
|
||||
dap.listeners.after["event_terminated"]["me"] = unset_hover_bind
|
||||
end
|
||||
},
|
||||
|
||||
{ "theHamsta/nvim-dap-virtual-text",
|
||||
reqs = {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
"mfussenegger/nvim-dap"
|
||||
},
|
||||
lazy = dep_short.cmd("DapVirtualTextToggle"),
|
||||
load = function()
|
||||
require("nvim-dap-virtual-text").setup {
|
||||
virt_text_pos = vim.fn.has("nvim-0.10") == 1 and "inline" or "eol",
|
||||
|
||||
--- A callback that determines how a variable is displayed or whether it should be omitted
|
||||
--- @param variable Variable https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable
|
||||
--- @param buf number
|
||||
--- @param stackframe dap.StackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame
|
||||
--- @param node userdata tree-sitter node identified as variable definition of reference (see `:h tsnode`)
|
||||
--- @param options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text
|
||||
--- @return string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed
|
||||
display_callback = function(variable, buf, stackframe, node, options)
|
||||
-- by default, strip out new line characters
|
||||
if options.virt_text_pos == "inline" then
|
||||
return " = "..variable.value:gsub("%s+", " ")
|
||||
else
|
||||
return variable.name.." = "..variable.value:gsub("%s+", " ")
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
},
|
||||
|
||||
{ "mfussenegger/nvim-dap-python",
|
||||
reqs = "mfussenegger/nvim-dap",
|
||||
lazy = dep_short.ft("python"),
|
||||
load = function()
|
||||
local debugpy = core.mason.get_pkg_path("debugpy", "/venv/bin/python3")
|
||||
require("dap-python").setup(debugpy)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user