2022-10-13 00:50:18 +00:00
|
|
|
local libmodal = require 'libmodal'
|
|
|
|
local daputils = require 'spike.dap.utils'
|
2022-09-23 00:50:02 +00:00
|
|
|
|
|
|
|
M = {}
|
|
|
|
M.layer = nil
|
|
|
|
|
2022-10-13 00:50:18 +00:00
|
|
|
|
2022-09-23 00:50:02 +00:00
|
|
|
local config = {
|
|
|
|
mappings = {
|
|
|
|
n =
|
2022-10-13 00:50:18 +00:00
|
|
|
{
|
|
|
|
t = { rhs = '<cmd> DapToggleBreakpoint<CR>', desc= '[dap] toggle breakpoint' },
|
2022-09-23 00:50:02 +00:00
|
|
|
T = {
|
|
|
|
rhs = function()
|
|
|
|
require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))
|
|
|
|
end,
|
2022-10-13 00:50:18 +00:00
|
|
|
desc = '[dap] conditional breakpoint',
|
2022-09-23 00:50:02 +00:00
|
|
|
},
|
|
|
|
c = {
|
|
|
|
rhs = function()
|
|
|
|
require('dap').continue()
|
|
|
|
end,
|
2022-10-13 00:50:18 +00:00
|
|
|
desc = '[dap] continue'
|
2022-09-23 00:50:02 +00:00
|
|
|
},
|
|
|
|
n = {
|
|
|
|
rhs = function()
|
|
|
|
require('dap').step_over()
|
|
|
|
end,
|
2022-10-13 00:50:18 +00:00
|
|
|
desc = '[dap] step over'
|
2022-09-23 00:50:02 +00:00
|
|
|
},
|
|
|
|
s = {
|
|
|
|
rhs = function()
|
|
|
|
require('dap').step_into()
|
|
|
|
end,
|
|
|
|
desc = '[dap] step into'
|
|
|
|
},
|
|
|
|
o = {
|
|
|
|
rhs = function()
|
|
|
|
require('dap').step_out()
|
|
|
|
end,
|
|
|
|
desc = '[dap] step out'
|
|
|
|
},
|
|
|
|
r = {
|
|
|
|
rhs = function()
|
2022-10-13 00:50:18 +00:00
|
|
|
require('dap').run_last()
|
2022-09-23 00:50:02 +00:00
|
|
|
end,
|
2022-10-13 00:50:18 +00:00
|
|
|
desc = '[dap] restart'
|
2022-09-23 00:50:02 +00:00
|
|
|
},
|
|
|
|
S = {
|
|
|
|
rhs = function()
|
2022-10-13 00:50:18 +00:00
|
|
|
daputils.disconnect_dap()
|
2022-09-23 00:50:02 +00:00
|
|
|
end,
|
2022-10-13 00:50:18 +00:00
|
|
|
desc = '[dap] stop'
|
2022-09-23 00:50:02 +00:00
|
|
|
},
|
|
|
|
C = {
|
|
|
|
rhs = function()
|
|
|
|
require('dap').run_to_cursor()
|
|
|
|
end,
|
2022-10-13 00:50:18 +00:00
|
|
|
desc = '[dap] run to curosr'
|
2022-09-23 00:50:02 +00:00
|
|
|
},
|
2022-10-09 02:51:47 +00:00
|
|
|
W = {
|
|
|
|
rhs = function()
|
2022-10-13 00:50:18 +00:00
|
|
|
require('dapui').float_element('watches')
|
2022-10-09 02:51:47 +00:00
|
|
|
end,
|
|
|
|
desc = '[dapui] float watches'
|
|
|
|
},
|
2022-10-16 23:50:45 +00:00
|
|
|
P = {
|
|
|
|
rhs = function()
|
|
|
|
require('dapui').float_element('scopes')
|
|
|
|
end,
|
|
|
|
desc = '[dapui] float scopes'
|
|
|
|
},B = {
|
2022-10-09 02:51:47 +00:00
|
|
|
rhs = function()
|
2022-10-13 00:50:18 +00:00
|
|
|
require('dapui').float_element('breakpoints')
|
2022-10-09 02:51:47 +00:00
|
|
|
end,
|
|
|
|
desc = '[dapui] float breakpoints'
|
|
|
|
},
|
|
|
|
O = {
|
|
|
|
rhs = function()
|
2022-10-13 00:50:18 +00:00
|
|
|
require('dapui').float_element('scopes')
|
2022-10-09 02:51:47 +00:00
|
|
|
end,
|
|
|
|
desc = '[dapui] float scopes'
|
|
|
|
},
|
2022-10-13 00:50:18 +00:00
|
|
|
['Q'] = {
|
2022-09-23 00:50:02 +00:00
|
|
|
rhs = function()
|
|
|
|
M.layer:exit()
|
|
|
|
end,
|
2022-10-13 00:50:18 +00:00
|
|
|
desc = '[dap] exit dap mode'
|
|
|
|
}
|
2022-09-23 00:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function M.start()
|
|
|
|
if M.layer == nil then
|
|
|
|
M.layer = libmodal.layer.new(config.mappings)
|
|
|
|
end
|
|
|
|
M.layer:enter()
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.stop()
|
|
|
|
if M.layer ~= nil then M.layer:exit() end
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.setup (opts)
|
2022-10-13 00:50:18 +00:00
|
|
|
config = vim.tbl_deep_extend('force', config, opts or {})
|
2022-09-23 00:50:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.is_active()
|
|
|
|
if M.layer == nil then return false end
|
|
|
|
return M.layer:is_active()
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- layer:map('n', '<Esc>', function() layer:exit() end, {})
|
|
|
|
-- --
|
|
|
|
-- layer:enter()
|
|
|
|
--
|
2022-10-13 00:50:18 +00:00
|
|
|
M.disconnect_dap = disconnect_dap
|
2022-09-23 00:50:02 +00:00
|
|
|
|
|
|
|
return M
|