switch to dap-view from dap-ui. Plus some light refactoring.
This commit is contained in:
parent
00a8c55353
commit
da76b3a048
1 changed files with 40 additions and 54 deletions
|
|
@ -1,34 +1,11 @@
|
||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
local inlay_hints_handler = require("inlay_hints_handler")
|
local inlay_hints_handler = require("inlay_hints_handler")
|
||||||
|
|
||||||
local are_stepping_keymaps_active = false
|
local is_debug_mode_active = false
|
||||||
return {
|
return {
|
||||||
"mfussenegger/nvim-dap",
|
"mfussenegger/nvim-dap",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
{
|
{ "igorlfs/nvim-dap-view", opts = {} },
|
||||||
"rcarriga/nvim-dap-ui",
|
|
||||||
opts = {
|
|
||||||
controls = {
|
|
||||||
enabled = false,
|
|
||||||
},
|
|
||||||
layouts = {
|
|
||||||
{
|
|
||||||
elements = {
|
|
||||||
{
|
|
||||||
id = "watches",
|
|
||||||
size = 0.5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = "stacks",
|
|
||||||
size = 0.5
|
|
||||||
}
|
|
||||||
},
|
|
||||||
position = "bottom",
|
|
||||||
size = 15
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
-- Special adapters
|
-- Special adapters
|
||||||
{ "leoluz/nvim-dap-go", opts = {} },
|
{ "leoluz/nvim-dap-go", opts = {} },
|
||||||
{ "mfussenegger/nvim-dap-python", },
|
{ "mfussenegger/nvim-dap-python", },
|
||||||
|
|
@ -52,28 +29,6 @@ return {
|
||||||
{ "i", function() dap.step_into() end },
|
{ "i", function() dap.step_into() end },
|
||||||
}
|
}
|
||||||
|
|
||||||
local function enter_debug_mode()
|
|
||||||
require("dapui").open()
|
|
||||||
if not are_stepping_keymaps_active then
|
|
||||||
utils.set_keymap_list(stepping_keymaps)
|
|
||||||
are_stepping_keymaps_active = true
|
|
||||||
end
|
|
||||||
|
|
||||||
inlay_hints_handler.disable()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function exit_debug_mode()
|
|
||||||
require("dapui").close()
|
|
||||||
if are_stepping_keymaps_active then
|
|
||||||
utils.del_keymap_list(stepping_keymaps)
|
|
||||||
are_stepping_keymaps_active = false
|
|
||||||
require("leap_keymap_handler").set_leap_keymapping()
|
|
||||||
end
|
|
||||||
|
|
||||||
inlay_hints_handler.restore()
|
|
||||||
virtual_text.clear_virtual_text()
|
|
||||||
end
|
|
||||||
|
|
||||||
local dap_signs = {
|
local dap_signs = {
|
||||||
{ "DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" } },
|
{ "DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" } },
|
||||||
{ "DapBreakpointRejected", { text = "🔵", texthl = "", linehl = "", numhl = "" } },
|
{ "DapBreakpointRejected", { text = "🔵", texthl = "", linehl = "", numhl = "" } },
|
||||||
|
|
@ -84,21 +39,52 @@ return {
|
||||||
vim.fn.sign_define(unpack(sign))
|
vim.fn.sign_define(unpack(sign))
|
||||||
end
|
end
|
||||||
|
|
||||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
local function enter_debug_mode()
|
||||||
enter_debug_mode()
|
if is_debug_mode_active then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
utils.set_keymap_list(stepping_keymaps)
|
||||||
|
is_debug_mode_active = true
|
||||||
|
|
||||||
|
inlay_hints_handler.disable()
|
||||||
|
require("dap-view").open()
|
||||||
end
|
end
|
||||||
dap.listeners.before.event_terminated["dapui_config"] = function()
|
|
||||||
exit_debug_mode()
|
local function exit_debug_mode()
|
||||||
|
if not is_debug_mode_active then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
utils.del_keymap_list(stepping_keymaps)
|
||||||
|
is_debug_mode_active = false
|
||||||
|
require("leap_keymap_handler").set_leap_keymapping()
|
||||||
|
|
||||||
|
inlay_hints_handler.restore()
|
||||||
|
virtual_text.clear_virtual_text()
|
||||||
|
require("dap-view").close()
|
||||||
end
|
end
|
||||||
dap.listeners.before.event_exited["dapui_config"] = function()
|
|
||||||
exit_debug_mode()
|
for _, request in ipairs({
|
||||||
|
{ "attach", enter_debug_mode },
|
||||||
|
{ "launch", enter_debug_mode },
|
||||||
|
}) do
|
||||||
|
dap.listeners.before[request[1]]["dapview"] = request[2]
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, event in ipairs({
|
||||||
|
{ "event_terminated", exit_debug_mode },
|
||||||
|
{ "event_exited", exit_debug_mode },
|
||||||
|
}) do
|
||||||
|
dap.listeners.after[event[1]]["dapview"] = event[2]
|
||||||
end
|
end
|
||||||
|
|
||||||
local function dap_stop()
|
local function dap_stop()
|
||||||
dap.disconnect({ terminateDebuggee = true })
|
dap.terminate()
|
||||||
dap.close()
|
dap.close()
|
||||||
exit_debug_mode()
|
exit_debug_mode()
|
||||||
end
|
end
|
||||||
|
|
||||||
utils.set_keymap_list({
|
utils.set_keymap_list({
|
||||||
{ "<leader>dr", dap.continue },
|
{ "<leader>dr", dap.continue },
|
||||||
{ "<leader>bt", breakpoint_api.toggle_breakpoint },
|
{ "<leader>bt", breakpoint_api.toggle_breakpoint },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue