fix debugging

This commit is contained in:
Christoph J. Scherr 2024-10-21 14:24:05 +02:00
parent d22718bf93
commit 286f7c4f94
6 changed files with 216 additions and 296 deletions

View File

@ -1,6 +1,6 @@
vim.g.mapleader = ' '
vim.g.maplocalleader = ';'
vim.g.python3_host_prog = '/usr/bin/python3'
-- vim.g.python3_host_prog = '/usr/bin/python3'
vim.opt.mouse = 'a' -- mouse does annoying things for me if it's not 'a'
vim.opt.signcolumn = 'yes'
@ -177,6 +177,7 @@ require 'custom.maps'
require 'custom.autocmds'
require('lazy').setup({
{ import = 'custom.plugins' },
{ import = 'kickstart.plugins.debug' },
}, {
ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the

View File

@ -142,6 +142,7 @@ local servers = {
html = {},
cssls = {},
clangd = {},
pyright = {},
bashls = {},
yamlls = {},
texlab = {},

View File

@ -76,10 +76,11 @@ return {
dependencies = { 'hrsh7th/nvim-cmp' },
config = function()
require('nvim-autopairs').setup {}
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require 'nvim-autopairs.completion.cmp'
local cmp = require 'cmp'
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
-- WARN: this is kind of anoying with rust, so I have disabeld it
-- -- If you want to automatically add `(` after selecting a function or method
-- local cmp_autopairs = require 'nvim-autopairs.completion.cmp'
-- local cmp = require 'cmp'
-- cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
end,
},
{

View File

@ -313,177 +313,6 @@ return {
},
},
{ 'kosayoda/nvim-lightbulb', event = { 'BufReadPre', 'BufNewFile' } },
{
'mfussenegger/nvim-dap',
lazy = false,
keys = {
{
'<leader>db',
function()
require('dap').toggle_breakpoint()
end,
desc = 'Set [D]ebug [B]reakpoint',
},
{
'<leader>dc',
function()
require('dap').continue()
end,
desc = '[D]ebug [C]ontinue',
},
{
'<leader>ds',
function()
require('dap').step_over()
end,
desc = 'Set [D]ebug [S]tep over',
},
{
'<leader>di',
function()
require('dap').step_into()
end,
desc = 'Set [D]ebug step [I]nto',
},
},
config = function()
local dap = require 'dap'
local mason_registry = require 'mason-registry'
local codelldb_root = mason_registry.get_package('codelldb'):get_install_path() .. '/extension/'
local codelldb_path = codelldb_root .. 'adapter/codelldb'
local liblldb_path = codelldb_root .. 'lldb/lib/liblldb.so'
dap.defaults.fallback.external_terminal = {
command = '/home/plex/.local/bin/kitty',
args = {},
}
dap.adapters.gdb = {
type = 'executable',
command = 'gdb',
args = { '-i', 'dap' },
}
dap.adapters.codelldb = {
type = 'server',
port = '30333',
executable = {
command = codelldb_path,
args = { '--port', '30333' },
detached = false,
},
}
dap.configurations.cpp = {
{
name = 'Launch file',
type = 'codelldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
args = function()
return require('custom.utils').tokenize_args(vim.fn.input 'args: ')
end,
cwd = '${workspaceFolder}',
-- FIXME: perhaps we can put the stdio somewhere more practical
stopOnEntry = false,
},
}
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
end,
},
{
'rcarriga/nvim-dap-ui',
keys = {
{
'<leader>du',
function()
require('dapui').toggle()
end,
desc = 'Open [D]ebug [U]i',
},
{
'<leader>dK',
function()
require('dap.ui.widgets').hover()
end,
desc = 'Open [D]ebug [K] hover',
},
{
'<leader>du',
function()
require('dapui').toggle()
end,
desc = 'Open [D]ebug [U]i',
},
{
'<leader>dws',
function()
local widgets = require 'dap.ui.widgets'
local my_sidebar = widgets.sidebar(widgets.scopes)
my_sidebar.open()
end,
desc = 'Open [D]ebug [W]indow [S]copes',
},
{
'<leader>dwf',
function()
local widgets = require 'dap.ui.widgets'
local my_sidebar = widgets.sidebar(widgets.frames)
my_sidebar.open()
end,
desc = 'Open [D]ebug [W]indow [F]rames',
},
{
'<leader>dwi',
function()
local widgets = require 'dap.ui.widgets'
local my_sidebar = widgets.sidebar(widgets.sessions)
my_sidebar.open()
end,
desc = 'Open [D]ebug [W]indow sess[I]ons',
},
{
'<leader>dwt',
function()
local widgets = require 'dap.ui.widgets'
local my_sidebar = widgets.sidebar(widgets.threads)
my_sidebar.open()
end,
desc = 'Open [D]ebug [W]indow [T]hreads',
},
{
'<leader>dwe',
function()
local widgets = require 'dap.ui.widgets'
local my_sidebar = widgets.sidebar(widgets.expression)
my_sidebar.open()
end,
desc = 'Open [D]ebug [W]indow [E]xpression',
},
},
dependencies = {
'mfussenegger/nvim-dap',
'nvim-neotest/nvim-nio',
},
config = function(_, opts)
local dap = require 'dap'
local dapui = require 'dapui'
dapui.setup(opts)
dap.listeners.after.event_initialized['dapui_config'] = function()
dapui.open {}
end
dap.listeners.before.event_terminated['dapui_config'] = function()
-- dapui.close {}
end
dap.listeners.before.event_exited['dapui_config'] = function()
-- dapui.close {}
end
end,
},
{
'folke/lazydev.nvim',
ft = 'lua', -- only load on lua files
@ -496,48 +325,4 @@ return {
},
},
{ 'Bilal2453/luvit-meta', lazy = true }, -- optional `vim.uv` typings
{
'mrcjkb/rustaceanvim',
enabled = false,
version = '^4', -- Recommended
ft = { 'rust' },
config = function()
local dap = require 'dap'
vim.g.rustaceanvim = {
enable_clippy = true,
-- Plugin configuration
tools = {
enable_clippy = true,
},
-- LSP configuration
server = {
on_attach = function(client, bufnr)
-- you can also put keymaps in here
end,
settings = {
-- rust-analyzer language server configuration
['rust-analyzer'] = {
cargo = {
features = 'all',
},
},
},
},
-- DAP configuration
dap = {
-- FIXME: the rustaceanvim debug config does not map the stdout/stderr to the
-- opened terminal, effectively rendering debugging with it useless. Luckily,
-- we can use the regular nvim-dap and nvim-dap-ui.
adapter = dap.adapters.codelldb,
},
}
end,
},
{
'theHamsta/nvim-dap-virtual-text',
lazy = false, -- PERF: this can be done more elegant
config = function()
require('nvim-dap-virtual-text').setup()
end,
},
}

View File

@ -7,90 +7,208 @@
-- kickstart.nvim and not kitchen-sink.nvim ;)
return {
-- NOTE: Yes, you can install new plugins here!
'mfussenegger/nvim-dap',
-- NOTE: And you can specify dependencies as well
dependencies = {
-- Creates a beautiful debugger UI
'rcarriga/nvim-dap-ui',
{
-- NOTE: Yes, you can install new plugins here!
'mfussenegger/nvim-dap',
-- NOTE: And you can specify dependencies as well
dependencies = {
-- Creates a beautiful debugger UI
-- Required dependency for nvim-dap-ui
'nvim-neotest/nvim-nio',
-- Required dependency for nvim-dap-ui
'nvim-neotest/nvim-nio',
-- Installs the debug adapters for you
'williamboman/mason.nvim',
'jay-babu/mason-nvim-dap.nvim',
-- Installs the debug adapters for you
'williamboman/mason.nvim',
'jay-babu/mason-nvim-dap.nvim',
-- Add your own debuggers here
'leoluz/nvim-dap-go',
},
config = function()
local dap = require 'dap'
local dapui = require 'dapui'
'theHamsta/nvim-dap-virtual-text',
},
config = function()
local dap = require 'dap'
local dapui = require 'dapui'
require('mason-nvim-dap').setup {
-- Makes a best effort to setup the various debuggers with
-- reasonable debug configurations
automatic_installation = true,
require('mason-nvim-dap').setup {
-- Makes a best effort to setup the various debuggers with
-- reasonable debug configurations
automatic_installation = true,
-- You can provide additional configuration to the handlers,
-- see mason-nvim-dap README for more information
handlers = {},
-- You can provide additional configuration to the handlers,
-- see mason-nvim-dap README for more information
handlers = {},
-- You'll need to check that you have the required things installed
-- online, please don't ask me how to install them :)
ensure_installed = {
-- Update this to ensure that you have the debuggers for the langs you want
'delve',
},
}
-- Basic debugging keymaps, feel free to change to your liking!
vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
vim.keymap.set('n', '<F1>', dap.step_into, { desc = 'Debug: Step Into' })
vim.keymap.set('n', '<F2>', dap.step_over, { desc = 'Debug: Step Over' })
vim.keymap.set('n', '<F3>', dap.step_out, { desc = 'Debug: Step Out' })
vim.keymap.set('n', '<leader>b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' })
vim.keymap.set('n', '<leader>B', function()
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
end, { desc = 'Debug: Set Breakpoint' })
-- Dap UI setup
-- For more information, see |:help nvim-dap-ui|
dapui.setup {
-- Set icons to characters that are more likely to work in every terminal.
-- Feel free to remove or use ones that you like more! :)
-- Don't feel like these are good choices.
icons = { expanded = '', collapsed = '', current_frame = '*' },
controls = {
icons = {
pause = '',
play = '',
step_into = '',
step_over = '',
step_out = '',
step_back = 'b',
run_last = '▶▶',
terminate = '',
disconnect = '',
-- You'll need to check that you have the required things installed
-- online, please don't ask me how to install them :)
ensure_installed = {
-- Update this to ensure that you have the debuggers for the langs you want
'codelldb',
'debugpy',
},
}
-- Basic debugging keymaps, feel free to change to your liking!
vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
vim.keymap.set('n', '<F1>', dap.step_into, { desc = 'Debug: Step Into' })
vim.keymap.set('n', '<F2>', dap.step_over, { desc = 'Debug: Step Over' })
vim.keymap.set('n', '<F3>', dap.step_out, { desc = 'Debug: Step Out' })
vim.keymap.set('n', '<leader>b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' })
vim.keymap.set('n', '<leader>B', function()
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
end, { desc = 'Debug: Set Breakpoint' })
-- Dap UI setup
-- For more information, see |:help nvim-dap-ui|
dapui.setup {
-- Set icons to characters that are more likely to work in every terminal.
-- Feel free to remove or use ones that you like more! :)
-- Don't feel like these are good choices.
icons = { expanded = '', collapsed = '', current_frame = '*' },
controls = {
icons = {
pause = '',
play = '',
step_into = '',
step_over = '',
step_out = '',
step_back = 'b',
run_last = '▶▶',
terminate = '',
disconnect = '',
},
},
}
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
vim.keymap.set('n', '<F7>', dapui.toggle, { desc = 'Debug: See last session result.' })
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
dap.listeners.before.event_exited['dapui_config'] = dapui.close
end,
},
{
'rcarriga/nvim-dap-ui',
keys = {
{
'<leader>du',
function()
require('dapui').toggle()
end,
desc = 'Open [D]ebug [U]i',
},
}
{
'<leader>dso',
function()
require('dap').step_over()
end,
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
vim.keymap.set('n', '<F7>', dapui.toggle, { desc = 'Debug: See last session result.' })
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
dap.listeners.before.event_exited['dapui_config'] = dapui.close
-- Install golang specific config
require('dap-go').setup {
delve = {
-- On Windows delve must be run attached or it crashes.
-- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring
detached = vim.fn.has 'win32' == 0,
desc = 'Toggle [D]ebug [S]tep [O]ver',
},
}
end,
{
'<leader>dsi',
function()
require('dap').step_into()
end,
desc = 'Toggle [D]ebug [S]tep [I]nto',
},
{
'<leader>dc',
function()
require('dap').continue()
end,
desc = 'Toggle [D]ebug [C]ontinue / Start',
},
{
'<leader>db',
function()
require('dap').toggle_breakpoint()
end,
desc = 'Toggle [D]ebug [B]reakpoint',
},
{
'<leader>dK',
function()
require('dap.ui.widgets').hover()
end,
desc = 'Open [D]ebug [K] hover',
},
{
'<leader>dws',
function()
local widgets = require 'dap.ui.widgets'
local my_sidebar = widgets.sidebar(widgets.scopes)
my_sidebar.open()
end,
desc = 'Open [D]ebug [W]indow [S]copes',
},
{
'<leader>dwr',
function()
require('dap').repl.toggle()
end,
desc = 'Open [D]ebug [W]indow [R]epl',
},
{
'<leader>dwf',
function()
local widgets = require 'dap.ui.widgets'
local my_sidebar = widgets.sidebar(widgets.frames)
my_sidebar.open()
end,
desc = 'Open [D]ebug [W]indow [F]rames',
},
{
'<leader>dwi',
function()
local widgets = require 'dap.ui.widgets'
local my_sidebar = widgets.sidebar(widgets.sessions)
my_sidebar.open()
end,
desc = 'Open [D]ebug [W]indow sess[I]ons',
},
{
'<leader>dwt',
function()
local widgets = require 'dap.ui.widgets'
local my_sidebar = widgets.sidebar(widgets.threads)
my_sidebar.open()
end,
desc = 'Open [D]ebug [W]indow [T]hreads',
},
{
'<leader>dwe',
function()
local widgets = require 'dap.ui.widgets'
local my_sidebar = widgets.sidebar(widgets.expression)
my_sidebar.open()
end,
desc = 'Open [D]ebug [W]indow [E]xpression',
},
},
dependencies = {
'mfussenegger/nvim-dap',
'nvim-neotest/nvim-nio',
},
config = function(_, opts)
local dap = require 'dap'
local dapui = require 'dapui'
dapui.setup(opts)
dap.listeners.after.event_initialized['dapui_config'] = function()
dapui.open {}
end
dap.listeners.before.event_terminated['dapui_config'] = function()
-- dapui.close {}
end
dap.listeners.before.event_exited['dapui_config'] = function()
-- dapui.close {}
end
end,
},
}

View File

@ -420,3 +420,17 @@ C3
TOTP
Panta/!
Panta
kauma
α
XEX
unintuitively
sea128
u8
Base64
ffield
α's
Vec
u128
number1
number2
i64