dap and dap ui + live-command and rust-tools updates

- setup signs for dap
- improved dap and dapmode keybindings
- live-command preview plugin
master
spike 2 years ago
parent fba0ef8038
commit b0ca1ac78d

@ -2,3 +2,7 @@ snippet fn
function() function()
$0 $0
end end
snippet lm
local M = {}
$0

@ -1,8 +1,8 @@
NVIM v0.8.0-dev-1194-ga80ab395a NVIM v0.9.0-dev-77-gf175ca9f7
Build type: RelWithDebInfo Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3 LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-10 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/cmake.config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include Compilation: /usr/bin/gcc-10 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/cmake.config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az220-425 Compiled by runner@fv-az47-468
Features: +acl +iconv +tui Features: +acl +iconv +tui
See ":help feature-compile" See ":help feature-compile"

@ -27,7 +27,16 @@ M.general = { --{{{
},--}}} },--}}}
n = {--{{{ n = {--{{{
["<ESC>"] = { "<cmd> noh <CR>", "no highlight" }, ["<ESC>"] = {
function()
if vim.o.filetype == "qf" then
vim.cmd("q")
else
vim.cmd("noh")
end
end,
"no highlight"
},
-- switch between windows -- switch between windows
["<C-h>"] = { "<C-w>h", "window left" }, ["<C-h>"] = { "<C-w>h", "window left" },
@ -146,8 +155,9 @@ M.general = { --{{{
}, },
-- quick close window -- quick close window
["<C-x>"] = {"<C-w>c", "close window"}, ["<C-x><C-x>"] = {"<C-w>c", "close window"},
-- Increase number is with double <C-a> and decrease with simple C-x
-- yank from cusor to eol to system and primary clipboard -- yank from cusor to eol to system and primary clipboard
@ -493,11 +503,19 @@ M.general = { --{{{
n = { n = {
["<leader>ds"] = { ["<leader>ds"] = {
function() function()
if vim.o.filetype == "go" then local mydap = require("spike.dap")
local spdap = require("spike.dap")
spdap.setup() mydap.setup()
spdap.go_debug() require('spike.dap.utils').init_breakpoints()
-- set a breakpoint at current line if there are none in
-- the project
if vim.o.filetype == "go" then
mydap.go_debug()
elseif vim.o.filetype == "rust" then
local rt = require("rust-tools")
-- make sure lsp is running ?
rt.debuggables.debuggables()
end end
end, end,
"start dap session" "start dap session"
@ -524,10 +542,18 @@ M.general = { --{{{
}, },
["<leader>dm"] = { ["<leader>dm"] = {
function() function()
require("spike.dapmode").start() require('spike.dap.dapmode').start()
end, end,
"enter dap mode" "enter dap mode"
} },
["<leader>dr"] = {"<cmd>lua require'dap'.run_last()<CR>", "[dap] rerun last"},
["<leader>dl"] = {
function()
require('spike.dap.utils').dap_logpoint()
end,
"[dap] add log point"
},
["<leader>dt"] = {"<cmd>lua require'dapui'.toggle()<CR>", "[dap] toggle UI"},
}, },
}-- }}} }-- }}}

@ -98,6 +98,7 @@ g.netrw_winsize = 20 -- width of the window (25%)
opt.signcolumn = "yes" opt.signcolumn = "yes"
opt.signcolumn = "auto:1-3" -- accommodate up to 3 icons
opt.splitbelow = true opt.splitbelow = true
opt.splitright = true opt.splitright = true
opt.termguicolors = true opt.termguicolors = true

@ -88,6 +88,21 @@ M.ui = {
fg = "grey", fg = "grey",
bg = "baby_pink", bg = "baby_pink",
}, },
DapBreakpoint = {
fg = "green"
},
DapStopped = {
fg = "#ff4848"
},
DapLogPoint = {
fg = "vibrant_green"
},
DapBreakpointCondition = {
fg = "cyan"
},
DapBreakpointRejected = {
fg = "purple"
}
}, },
-- hl_override = { -- hl_override = {
-- CursorLine = { -- CursorLine = {
@ -108,13 +123,6 @@ M.ui = {
M.plugins = { M.plugins = {
user = require "custom.plugins", user = require "custom.plugins",
override = { override = {
["folke/which-key.nvim"] = {
triggers_blacklist = {
-- list of mode / prefixes that should never be hooked by WhichKey
i = { "j", "k" },
v = { "j", "k" },
},
},
["NvChad/ui"] = { ["NvChad/ui"] = {
-- tabufline = { -- tabufline = {
-- lazyload = false, -- lazyload = false,

@ -37,13 +37,14 @@ vim.cmd [[
-- suckless { -- suckless {
vim.cmd [[ vim.cmd [[
" Autocompile suckless " Autocompile suckless
let dwm_file_patterns = expand("$HOME/.local/src/suckless/*/{config.h,*.c}") " NOTE: symlinks do not work with autocommand patterns
let dwm_file_patterns = expand("/data/source/suckless/*/{config.h,*.c}")
augroup DWM augroup DWM
au! au!
execute "au BufEnter " . dwm_file_patterns . " :lcd %:p:h" execute "au BufEnter " . dwm_file_patterns . " :lcd %:p:h"
execute "au BufWrite " . dwm_file_patterns . " :AsyncRun! make clean && make && sudo make install" execute "au BufWritePost " . dwm_file_patterns . " :AsyncRun! make clean && make && sudo make install"
"au BufWrite */src/*/dwm*/{*.h,dwm.c} :AsyncRun! make clean && make && sudo make install "au BufWrite */src/*/dwm*/{*.h,dwm.c} :AsyncRun! make clean && make && sudo make install
augroup END augroup END
]] ]]

@ -0,0 +1,10 @@
-- local dap = require("dap")
local M = {}
local opts = {
}
M.setup = function()
end
return M

@ -0,0 +1,82 @@
local dapui = require('dapui')
local M = {}
local opts = {
icons = { expanded = "", collapsed = "", current_frame = "" },
mappings = {
-- Use a table to apply multiple mappings
expand = { "<CR>", "<2-LeftMouse>" },
open = "o",
remove = "d",
edit = "e",
repl = "r",
toggle = "t",
},
-- Expand lines larger than the window
-- Requires >= 0.7
expand_lines = vim.fn.has("nvim-0.7") == 1,
-- Layouts define sections of the screen to place windows.
-- The position can be "left", "right", "top" or "bottom".
-- The size specifies the height/width depending on position. It can be an Int
-- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while
-- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns)
-- Elements are the elements shown in the layout (in order).
-- Layouts are opened in order so that earlier layouts take priority in window sizing.
layouts = {
{
elements = {
-- Elements can be strings or table with id and size keys.
{ id = "scopes", size = 0.25 },
"breakpoints",
"stacks",
-- "watches",
},
size = 40, -- 40 columns
position = "left",
},
{
elements = {
"repl",
"watches"
-- "console",
},
size = 0.25, -- 25% of total lines
position = "bottom",
},
},
controls = {
-- Requires Neovim nightly (or 0.8 when released)
enabled = true,
-- Display controls in this element
element = "repl",
icons = {
pause = "",
play = "",
step_into = "",
step_over = "",
step_out = "",
step_back = "",
run_last = "",
terminate = "",
},
},
floating = {
max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil, -- Floats will be treated as percentage of your screen.
border = "single", -- Border style. Can be "single", "double" or "rounded"
mappings = {
close = { "q", "<Esc>" },
},
},
windows = { indent = 1 },
render = {
max_type_length = nil, -- Can be integer or nil.
max_value_lines = 100, -- Can be integer or nil.
}
}
M.setup = function()
dapui.setup(opts)
end
return M

@ -0,0 +1,42 @@
local M = {}
local opts = {
defaults = {
enable_highlighting = true,
inline_highlighting = true,
hl_groups = {
insertion = "DiffAdd",
deletion = "DiffDelete",
change = "DiffChange",
},
},
debug = true,
commands = {
Norm = { cmd = "norm" },
Reg = {
cmd = "norm",
-- This will transform ":5Reg a" into ":norm 5@a"
args = function(opts)
return (opts.count == -1 and "" or opts.count) .. "@" .. opts.args
end,
range = "",
},
}
}
function M.get_cmds()
local cmds = {}
for cmd, _ in pairs(opts.commands) do
table.insert(cmds, cmd)
end
return cmds
end
function M.setup()
require("live-command").setup(opts)
end
return M

@ -47,7 +47,7 @@ local config = {
{ key = 'gL', func = require('navigator.diagnostics').show_diagnostics, desc = 'lsp show_diagnostics' }, { key = 'gL', func = require('navigator.diagnostics').show_diagnostics, desc = 'lsp show_diagnostics' },
{ key = 'gG', func = require('navigator.diagnostics').show_buf_diagnostics, desc = 'lsp show_buf_diagnostics' }, { key = 'gG', func = require('navigator.diagnostics').show_buf_diagnostics, desc = 'lsp show_buf_diagnostics' },
-- { key = '<Leader>dt', func = require('navigator.diagnostics').toggle_diagnostics, desc = 'lsp toggle_diagnostics' }, -- { key = '<Leader>dt', func = require('navigator.diagnostics').toggle_diagnostics, desc = 'lsp toggle_diagnostics' },
{ key = '<Leader>dt', func = require('spike.lsp').toggle_diagnostics, desc = 'lsp toggle_diagnostics' }, { key = '<Leader>td', func = require('spike.lsp').toggle_diagnostics, desc = 'lsp toggle_diagnostics' },
{ key = ']d', func = vim.diagnostic.goto_next, desc = 'lsp next diagnostics' }, { key = ']d', func = vim.diagnostic.goto_next, desc = 'lsp next diagnostics' },
{ key = '[d', func = vim.diagnostic.goto_prev, desc = 'lsp prev diagnostics' }, { key = '[d', func = vim.diagnostic.goto_prev, desc = 'lsp prev diagnostics' },
{ key = ']O', func = vim.diagnostic.set_loclist, desc = 'lsp diagnostics set loclist' }, { key = ']O', func = vim.diagnostic.set_loclist, desc = 'lsp diagnostics set loclist' },
@ -56,13 +56,13 @@ local config = {
{ key = '<C-LeftMouse>', func = vim.lsp.buf.definition, desc = 'lsp definition' }, { key = '<C-LeftMouse>', func = vim.lsp.buf.definition, desc = 'lsp definition' },
{ key = 'g<LeftMouse>', func = vim.lsp.buf.implementation, desc = 'lsp implementation' }, { key = 'g<LeftMouse>', func = vim.lsp.buf.implementation, desc = 'lsp implementation' },
{ key = '<Leader>k', func = require('navigator.dochighlight').hi_symbol, desc = 'lsp hi_symbol' }, { key = '<Leader>k', func = require('navigator.dochighlight').hi_symbol, desc = 'lsp hi_symbol' },
{ key = '<Space>wa', func = require('navigator.workspace').add_workspace_folder, desc = 'lsp add_workspace_folder' }, { key = '<leader>wa', func = require('navigator.workspace').add_workspace_folder, desc = 'lsp add_workspace_folder' },
{ {
key = '<Space>wr', key = '<leader>wr',
func = require('navigator.workspace').remove_workspace_folder, func = require('navigator.workspace').remove_workspace_folder,
desc = 'lsp lsp remove_workspace_folder', desc = 'lsp lsp remove_workspace_folder',
}, },
{ key = '<Space>ff', func = vim.lsp.buf.format, mode = 'n', desc = 'lsp format' }, { key = '<space>fm', func = vim.lsp.buf.format, mode = 'n', desc = 'lsp format' },
-- { key = '<Space>ff', func = vim.lsp.buf.range_formatting, mode = 'v', desc = 'lsp range format' }, -- { key = '<Space>ff', func = vim.lsp.buf.range_formatting, mode = 'v', desc = 'lsp range format' },
-- DEPRECATED -- DEPRECATED
-- { -- {
@ -71,8 +71,8 @@ local config = {
-- mode = 'n', -- mode = 'n',
-- desc = 'lsp range format operator e.g gmip', -- desc = 'lsp range format operator e.g gmip',
-- }, -- },
{ key = '<Space>wl', func = require('navigator.workspace').list_workspace_folders, desc = 'lsp list_workspace_folders' }, { key = '<leader>wl', func = require('navigator.workspace').list_workspace_folders, desc = 'lsp list_workspace_folders' },
{ key = '<Space>la', mode = 'n', func = require('navigator.codelens').run_action, desc = 'lsp run code lens action' }, { key = '<leader>ll', mode = 'n', func = require('navigator.codelens').run_action, desc = 'lsp run code lens action' },
}, },
icons = { icons = {

@ -171,6 +171,7 @@ local opts = {
type = "executable", type = "executable",
command = "lldb-vscode", command = "lldb-vscode",
name = "rt_lldb", name = "rt_lldb",
console = "integratedTerminal",
}, },
}, },
} }

@ -142,7 +142,7 @@ return {
["tpope/vim-surround"] = {}, ["tpope/vim-surround"] = {},
["godlygeek/tabular"] = { ["godlygeek/tabular"] = {
cmd = "Tabularize" lcmd = "Tabularize"
}, -- }}} }, -- }}}
@ -158,12 +158,19 @@ return {
module = "dap", module = "dap",
setup = function() setup = function()
require("core.utils").load_mappings "dap" require("core.utils").load_mappings "dap"
require('spike.dap').setup()
end, end,
config = function()
require("custom.plugins.configs.dap").setup()
end
}, },
["rcarriga/nvim-dap-ui"] = { ["rcarriga/nvim-dap-ui"] = {
tag = "*", tag = "*",
after = "nvim-dap", after = "nvim-dap",
config = function()
require('custom.plugins.configs.dapui').setup()
end
}, },
["theHamsta/nvim-dap-virtual-text"] = { ["theHamsta/nvim-dap-virtual-text"] = {
@ -172,11 +179,22 @@ return {
}, -- }}} }, -- }}}
-- User Interface / UX -- User Interface / UX
--
-- allows to preview commands after they are registerd by plugin
-- the current registerd norm command works by first selecting a visual selection
-- then doing the changes, it's an enhanced multi cursor
["smjonas/live-command.nvim"] = {
cmd = require("custom.plugins.configs.live-command").get_cmds(),
opt = true,
config = function()
require("custom.plugins.configs.live-command").setup()
end
},
["folke/which-key.nvim"] = { -- {{{ ["folke/which-key.nvim"] = { -- {{{
lock = true, lock = true,
disable = false, disable = false,
keys = {"<leader>", "<BS>", "<Space>"} keys = { "<leader>", "<BS>", "<Space>", "\"", "`", "'", "z", "g" }
}, },
-- repeat operator for plugin commands -- repeat operator for plugin commands
@ -186,8 +204,6 @@ return {
["nvim-telescope/telescope.nvim"] = { ["nvim-telescope/telescope.nvim"] = {
-- lock = true, -- lock = true,
after = "vim-hardtime",
disable = false, disable = false,
}, },
["tom-anders/telescope-vim-bookmarks.nvim"] = { ["tom-anders/telescope-vim-bookmarks.nvim"] = {
@ -221,7 +237,7 @@ return {
}, -- }}} }, -- }}}
-- Theme customization -- Theme customization
["uga-rosa/ccc.nvim"] = { ["uga-rosa/ccc.nvim"] = { -- {{{{{{
commit = "427471b", commit = "427471b",
cmd = { "Ccc*", "<Plug>(ccc-insert)" }, cmd = { "Ccc*", "<Plug>(ccc-insert)" },
setup = function() setup = function()
@ -230,9 +246,10 @@ return {
config = function() config = function()
require("ccc").setup({}) require("ccc").setup({})
end end
}, }, -- }}}}}}
-- navigation / jumping / buffer modification
-- navigation / jumps
-- ["justinmk/vim-sneak"] = { -- ["justinmk/vim-sneak"] = {
-- lock = true, -- lock = true,
-- keys = {"s", "S"}, -- keys = {"s", "S"},
@ -260,6 +277,7 @@ return {
-- Job management (use nvim startjob ) -- Job management (use nvim startjob )
-- Run async commands (make & errors) -- Run async commands (make & errors)
-- TODO: replace with https://github.com/skywind3000/asynctasks.vim
["skywind3000/asyncrun.vim"] = { -- {{{ ["skywind3000/asyncrun.vim"] = { -- {{{
lock = true, lock = true,
cmd = "AsyncRun", cmd = "AsyncRun",
@ -292,41 +310,55 @@ return {
-- Misc / General plugins -- Misc / General plugins
-- Read info files -- Read info files
["https://gitlab.com/HiPhish/info.vim.git"] = { ["https://gitlab.com/HiPhish/info.vim.git"] = { -- {{{{{{
cmd = "Info", cmd = "Info",
}, }, -- }}}}}}
["MattesGroeger/vim-bookmarks"] = { ["MattesGroeger/vim-bookmarks"] = { -- {{{
config = function() config = function()
require("core.utils").load_mappings "vim_bookmarks" require("core.utils").load_mappings "vim_bookmarks"
end end
}, }, -- }}}
-- create new vim modes -- create new vim modes
["Iron-E/nvim-libmodal"] = { ["Iron-E/nvim-libmodal"] = { -- {{{
lock = true, lock = true,
}, }, -- }}}
-- get rid of bad habits -- get rid of bad habits
["takac/vim-hardtime"] = { -- ["ja-ford/delaytrain.nvim"] = {
-- keys = { "h", "j", "k", "l" }, ["~/src/delaytrain.nvim"] = {
setup = function() config = function()
vim.g.hardtime_default_on = 1 require('delaytrain').setup({
vim.g.hardtime_showmsg = 1 delay_ms = 1000, -- How long repeated usage of a key should be prevented
vim.g.list_of_normal_keys = {"h","j","k","l"} grace_period = 1, -- How many repeated keypresses are allowed
vim.g.list_of_visual_keys = {"h","j","k","l"} keys = { -- Which keys (in which modes) should be delayed
vim.g.hardtime_ignore_quickfix = 1 ['nv'] = { 'h', 'j', 'k', 'l' },
vim.g.hardtime_ignore_buffer_patterns = { -- ['nvi'] = { '<Left>', '<Down>', '<Up>', '<Right>' },
"NERD.*",
"netrw",
"TelescopePrompt",
"fugitive",
"guihua*",
}
vim.g.hardtime_maxcount = 2
end,
}, },
ignore_filetypes = {"qf", "NvimTree", "help", "qf", "netrw"},
})
end
},
-- ["takac/vim-hardtime"] = {-- {{{
-- -- keys = { "h", "j", "k", "l" },
-- setup = function()
-- vim.g.hardtime_default_on = 1
-- vim.g.hardtime_showmsg = 1
-- vim.g.list_of_normal_keys = {"h","j","k","l"}
-- vim.g.list_of_visual_keys = {"h","j","k","l"}
-- vim.g.hardtime_ignore_quickfix = 1
-- vim.g.hardtime_ignore_buffer_patterns = {
-- "NERD.*",
-- "netrw",
-- "TelescopePrompt",
-- "fugitive",
-- "guihua*",
-- }
-- vim.g.hardtime_maxcount = 2
-- end,
-- },-- }}}
-- ["chentoast/marks.nvim"] = { -- ["chentoast/marks.nvim"] = {
-- opt = true, -- opt = true,

@ -37,7 +37,7 @@ local modes = {
} }
local function is_dapmode() local function is_dapmode()
return require("spike.dapmode").is_active() return require("spike.dap.dapmode").is_active()
-- return false -- return false
end end

@ -65,8 +65,14 @@ local options = {
["<C-n>"] = cmp.mapping.select_next_item(), ["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4), ["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-e>"] = cmp.mapping.complete(), -- Try to emulate native neovim C-x completion style behavior
["<C-e><C-e>"] = cmp.mapping.complete(),
["<C-c>"] = cmp.mapping.close(), ["<C-c>"] = cmp.mapping.close(),
["<C-e>"] = cmp.mapping.abort(),
["<C-y>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
["<CR>"] = cmp.mapping.confirm { ["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = false, select = false,

@ -7,6 +7,7 @@ end
require("base46").load_highlight "whichkey" require("base46").load_highlight "whichkey"
local options = { local options = {
registers = true,
icons = { icons = {
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
@ -33,7 +34,7 @@ local options = {
-- list of mode / prefixes that should never be hooked by WhichKey -- list of mode / prefixes that should never be hooked by WhichKey
i = { "j", "k" }, i = { "j", "k" },
v = { "j", "k" }, v = { "j", "k" },
n = { "`", "'", "\"", "@"}, -- n = { "\"", "@" }, -- disable registers
}, },
} }

@ -1,33 +0,0 @@
local dapmode = require("spike.dapmode")
local M = {}
local function register_listeners()
local present, dap = pcall(require, "dap")
if not present then
print("nvim-dap missing !")
return
end
dap.listeners.before['event_initialized']['spike-dap'] = function(session, body)
dapmode.start()
end
dap.listeners.after['event_terminated']['spike-dap'] = function(session, body)
-- print("dap session ended")
dapmode.stop()
end
end
function M.go_debug()
local present, gdap = pcall(require, "go.dap")
if not present then return end
gdap.run()
end
function M.setup()
dapmode.setup({})
register_listeners()
end
return M

@ -1,30 +1,32 @@
local libmodal = require "libmodal" local libmodal = require 'libmodal'
local daputils = require 'spike.dap.utils'
M = {} M = {}
M.layer = nil M.layer = nil
local config = { local config = {
mappings = { mappings = {
n = n =
{ {
t = { rhs = '<cmd> DapToggleBreakpoint<CR>', desc= "[dap] toggle breakpoint" }, t = { rhs = '<cmd> DapToggleBreakpoint<CR>', desc= '[dap] toggle breakpoint' },
T = { T = {
rhs = function() rhs = function()
require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: ')) require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))
end, end,
desc = "[dap] conditional breakpoint", desc = '[dap] conditional breakpoint',
}, },
c = { c = {
rhs = function() rhs = function()
require('dap').continue() require('dap').continue()
end, end,
desc = "[dap] continue" desc = '[dap] continue'
}, },
n = { n = {
rhs = function() rhs = function()
require('dap').step_over() require('dap').step_over()
end, end,
desc = "[dap] step over" desc = '[dap] step over'
}, },
s = { s = {
rhs = function() rhs = function()
@ -40,45 +42,45 @@ local config = {
}, },
r = { r = {
rhs = function() rhs = function()
require('go.dap').run() require('dap').run_last()
end, end,
desc = '[dap] run' desc = '[dap] restart'
}, },
S = { S = {
rhs = function() rhs = function()
require('go.dap').stop() daputils.disconnect_dap()
end, end,
desc = "[dap] stop" desc = '[dap] stop'
}, },
C = { C = {
rhs = function() rhs = function()
require('dap').run_to_cursor() require('dap').run_to_cursor()
end, end,
desc = "[dap] run to curosr" desc = '[dap] run to curosr'
}, },
W = { W = {
rhs = function() rhs = function()
require("dapui").float_element('watches') require('dapui').float_element('watches')
end, end,
desc = '[dapui] float watches' desc = '[dapui] float watches'
}, },
B = { B = {
rhs = function() rhs = function()
require("dapui").float_element('breakpoints') require('dapui').float_element('breakpoints')
end, end,
desc = '[dapui] float breakpoints' desc = '[dapui] float breakpoints'
}, },
O = { O = {
rhs = function() rhs = function()
require("dapui").float_element('scopes') require('dapui').float_element('scopes')
end, end,
desc = '[dapui] float scopes' desc = '[dapui] float scopes'
}, },
["Q"] = { ['Q'] = {
rhs = function() rhs = function()
M.layer:exit() M.layer:exit()
end, end,
desc = "[dap] exit dap mode" desc = '[dap] exit dap mode'
} }
} }
} }
@ -97,7 +99,7 @@ function M.stop()
end end
function M.setup (opts) function M.setup (opts)
config = vim.tbl_deep_extend("force", config, opts or {}) config = vim.tbl_deep_extend('force', config, opts or {})
end end
function M.is_active() function M.is_active()
@ -110,5 +112,6 @@ end
-- -- -- --
-- layer:enter() -- layer:enter()
-- --
M.disconnect_dap = disconnect_dap
return M return M

@ -0,0 +1,70 @@
local dapmode = require("spike.dap.dapmode")
local daputils = require('spike.dap.utils')
local dapui = require("dapui")
local M = {}
M.signs = {
DapBreakpoint = {
icon = '',
hl = 'DapBreakpoint'
},
DapLogPoint = {
icon = '',
hl = 'DapLogPoint',
},
DapStopped = {
icon = '',
hl = 'DapStopped',
},
DapBreakpointCondition = {
icon = '',
hl = 'DapBreakpointCondition',
},
DapBreakpointRejected = {
icon = '',
hl = 'DapBreakpointRejected'
}
}
local function register_listeners()
local present, dap = pcall(require, "dap")
if not present then
print("nvim-dap missing !")
return
end
dap.listeners.before['event_initialized']['spike-dap'] = function(session, body)
dapmode.start()
dapui.open()
end
dap.listeners.after['event_terminated']['spike-dap'] = function(session, body)
-- print("dap session ended")
dapmode.stop()
dapui.close()
end
end
function M.go_debug()
local present, gdap = pcall(require, "go.dap")
if not present then return end
gdap.run()
end
local function set_signs()
for sign, conf in pairs(M.signs) do
vim.fn.sign_define(sign, {text = conf.icon, texthl=conf.hl})
end
end
function M.prepare_launch()
end
function M.setup()
dapmode.setup({})
register_listeners()
set_signs()
end
return M

@ -0,0 +1,35 @@
local ok, dap = pcall(require, 'dap')
if not ok then
vim.notify('dap module missing')
end
local M = {}
M.disconnect_dap = function()
local has_dap, dap = pcall(require, 'dap')
if has_dap then
dap.disconnect()
dap.repl.close()
vim.cmd('sleep 100m') -- allow cleanup
else
vim.notify('dap not found')
end
end
M.dap_logpoint = function()
vim.ui.input({ prompt = 'Logpoint message> '}, function (input)
dap.set_breakpoint(nil,nil,input)
end)
end
-- if there are no breakpoints in the project set a breakpoint on the current
-- line
M.init_breakpoints = function()
-- see https://github.com/rcarriga/nvim-dap-ui/blob/master/lua/dapui/state.lua
-- for a reference to access dap breakpoint details
local breakpoints = require('dap.breakpoints').get() or {}
if #breakpoints == 0 then
dap.set_breakpoint()
end
end
return M

@ -18,3 +18,13 @@ R = function(name)
RELOAD(name) RELOAD(name)
return require(name) return require(name)
end end
TBL_HASVAL = function(tab, val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end

Loading…
Cancel
Save