From 286f7c4f94b760e13880071fe392ae78f38b8ab7 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Mon, 21 Oct 2024 14:24:05 +0200 Subject: [PATCH] fix debugging --- init.lua | 3 +- lua/custom/plugins/configs/lsp.lua | 1 + lua/custom/plugins/editing.lua | 9 +- lua/custom/plugins/lsp.lua | 215 ----------------------- lua/kickstart/plugins/debug.lua | 270 +++++++++++++++++++++-------- spell/en.utf-8.add | 14 ++ 6 files changed, 216 insertions(+), 296 deletions(-) diff --git a/init.lua b/init.lua index 54eac27..383dcc7 100644 --- a/init.lua +++ b/init.lua @@ -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 diff --git a/lua/custom/plugins/configs/lsp.lua b/lua/custom/plugins/configs/lsp.lua index 0329bd3..b9c5ecf 100644 --- a/lua/custom/plugins/configs/lsp.lua +++ b/lua/custom/plugins/configs/lsp.lua @@ -142,6 +142,7 @@ local servers = { html = {}, cssls = {}, clangd = {}, + pyright = {}, bashls = {}, yamlls = {}, texlab = {}, diff --git a/lua/custom/plugins/editing.lua b/lua/custom/plugins/editing.lua index d883387..9ad8d94 100644 --- a/lua/custom/plugins/editing.lua +++ b/lua/custom/plugins/editing.lua @@ -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, }, { diff --git a/lua/custom/plugins/lsp.lua b/lua/custom/plugins/lsp.lua index b399893..271eb33 100644 --- a/lua/custom/plugins/lsp.lua +++ b/lua/custom/plugins/lsp.lua @@ -313,177 +313,6 @@ return { }, }, { 'kosayoda/nvim-lightbulb', event = { 'BufReadPre', 'BufNewFile' } }, - { - 'mfussenegger/nvim-dap', - lazy = false, - keys = { - { - 'db', - function() - require('dap').toggle_breakpoint() - end, - desc = 'Set [D]ebug [B]reakpoint', - }, - { - 'dc', - function() - require('dap').continue() - end, - desc = '[D]ebug [C]ontinue', - }, - { - 'ds', - function() - require('dap').step_over() - end, - desc = 'Set [D]ebug [S]tep over', - }, - { - '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 = { - { - 'du', - function() - require('dapui').toggle() - end, - - desc = 'Open [D]ebug [U]i', - }, - { - 'dK', - function() - require('dap.ui.widgets').hover() - end, - - desc = 'Open [D]ebug [K] hover', - }, - { - 'du', - function() - require('dapui').toggle() - end, - - desc = 'Open [D]ebug [U]i', - }, - { - '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', - }, - { - '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', - }, - { - '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', - }, - { - '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', - }, - { - '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, - }, } diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 31dfecf..e961b1d 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -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', '', dap.continue, { desc = 'Debug: Start/Continue' }) - vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) - vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) - vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) - vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) - vim.keymap.set('n', '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', '', dap.continue, { desc = 'Debug: Start/Continue' }) + vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) + vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) + vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) + vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) + vim.keymap.set('n', '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', '', 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 = { + { + 'du', + function() + require('dapui').toggle() + end, + + desc = 'Open [D]ebug [U]i', }, - } + { + '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', '', 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, + { + 'dsi', + function() + require('dap').step_into() + end, + + desc = 'Toggle [D]ebug [S]tep [I]nto', + }, + { + 'dc', + function() + require('dap').continue() + end, + + desc = 'Toggle [D]ebug [C]ontinue / Start', + }, + { + 'db', + function() + require('dap').toggle_breakpoint() + end, + + desc = 'Toggle [D]ebug [B]reakpoint', + }, + { + 'dK', + function() + require('dap.ui.widgets').hover() + end, + + desc = 'Open [D]ebug [K] hover', + }, + { + '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', + }, + { + 'dwr', + function() + require('dap').repl.toggle() + end, + + desc = 'Open [D]ebug [W]indow [R]epl', + }, + { + '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', + }, + { + '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', + }, + { + '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', + }, + { + '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, + }, } diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add index 0027924..d7f963a 100644 --- a/spell/en.utf-8.add +++ b/spell/en.utf-8.add @@ -420,3 +420,17 @@ C3 TOTP Panta/! Panta +kauma +α +XEX +unintuitively +sea128 +u8 +Base64 +ffield +α's +Vec +u128 +number1 +number2 +i64