You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
2.4 KiB
Lua
118 lines
2.4 KiB
Lua
2 years ago
|
local libmodal = require 'libmodal'
|
||
|
local daputils = require 'spike.dap.utils'
|
||
2 years ago
|
|
||
|
M = {}
|
||
|
M.layer = nil
|
||
|
|
||
2 years ago
|
|
||
2 years ago
|
local config = {
|
||
|
mappings = {
|
||
|
n =
|
||
2 years ago
|
{
|
||
|
t = { rhs = '<cmd> DapToggleBreakpoint<CR>', desc= '[dap] toggle breakpoint' },
|
||
2 years ago
|
T = {
|
||
|
rhs = function()
|
||
|
require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))
|
||
|
end,
|
||
2 years ago
|
desc = '[dap] conditional breakpoint',
|
||
2 years ago
|
},
|
||
|
c = {
|
||
|
rhs = function()
|
||
|
require('dap').continue()
|
||
|
end,
|
||
2 years ago
|
desc = '[dap] continue'
|
||
2 years ago
|
},
|
||
|
n = {
|
||
|
rhs = function()
|
||
|
require('dap').step_over()
|
||
|
end,
|
||
2 years ago
|
desc = '[dap] step over'
|
||
2 years ago
|
},
|
||
|
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()
|
||
2 years ago
|
require('dap').run_last()
|
||
2 years ago
|
end,
|
||
2 years ago
|
desc = '[dap] restart'
|
||
2 years ago
|
},
|
||
|
S = {
|
||
|
rhs = function()
|
||
2 years ago
|
daputils.disconnect_dap()
|
||
2 years ago
|
end,
|
||
2 years ago
|
desc = '[dap] stop'
|
||
2 years ago
|
},
|
||
|
C = {
|
||
|
rhs = function()
|
||
|
require('dap').run_to_cursor()
|
||
|
end,
|
||
2 years ago
|
desc = '[dap] run to curosr'
|
||
2 years ago
|
},
|
||
2 years ago
|
W = {
|
||
|
rhs = function()
|
||
2 years ago
|
require('dapui').float_element('watches')
|
||
2 years ago
|
end,
|
||
|
desc = '[dapui] float watches'
|
||
|
},
|
||
|
B = {
|
||
|
rhs = function()
|
||
2 years ago
|
require('dapui').float_element('breakpoints')
|
||
2 years ago
|
end,
|
||
|
desc = '[dapui] float breakpoints'
|
||
|
},
|
||
|
O = {
|
||
|
rhs = function()
|
||
2 years ago
|
require('dapui').float_element('scopes')
|
||
2 years ago
|
end,
|
||
|
desc = '[dapui] float scopes'
|
||
|
},
|
||
2 years ago
|
['Q'] = {
|
||
2 years ago
|
rhs = function()
|
||
|
M.layer:exit()
|
||
|
end,
|
||
2 years ago
|
desc = '[dap] exit dap mode'
|
||
|
}
|
||
2 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
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)
|
||
2 years ago
|
config = vim.tbl_deep_extend('force', config, opts or {})
|
||
2 years ago
|
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()
|
||
|
--
|
||
2 years ago
|
M.disconnect_dap = disconnect_dap
|
||
2 years ago
|
|
||
|
return M
|