my-nvim-lua/lua/spike/dap/dapmode.lua

123 lines
2.5 KiB
Lua
Raw Normal View History

local libmodal = require 'libmodal'
local daputils = require 'spike.dap.utils'
2022-09-23 00:50:02 +00:00
M = {}
M.layer = nil
2022-09-23 00:50:02 +00:00
local config = {
mappings = {
n =
{
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,
desc = '[dap] conditional breakpoint',
2022-09-23 00:50:02 +00:00
},
c = {
rhs = function()
require('dap').continue()
end,
desc = '[dap] continue'
2022-09-23 00:50:02 +00:00
},
n = {
rhs = function()
require('dap').step_over()
end,
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()
require('dap').run_last()
2022-09-23 00:50:02 +00:00
end,
desc = '[dap] restart'
2022-09-23 00:50:02 +00:00
},
S = {
rhs = function()
daputils.disconnect_dap()
2022-09-23 00:50:02 +00:00
end,
desc = '[dap] stop'
2022-09-23 00:50:02 +00:00
},
C = {
rhs = function()
require('dap').run_to_cursor()
end,
desc = '[dap] run to curosr'
2022-09-23 00:50:02 +00:00
},
2022-10-09 02:51:47 +00:00
W = {
rhs = function()
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()
require('dapui').float_element('breakpoints')
2022-10-09 02:51:47 +00:00
end,
desc = '[dapui] float breakpoints'
},
O = {
rhs = function()
require('dapui').float_element('scopes')
2022-10-09 02:51:47 +00:00
end,
desc = '[dapui] float scopes'
},
['Q'] = {
2022-09-23 00:50:02 +00:00
rhs = function()
M.layer:exit()
end,
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)
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()
--
M.disconnect_dap = disconnect_dap
2022-09-23 00:50:02 +00:00
return M