From 29264ecaa8307c01e32978ad8cc52781cfafdb9b Mon Sep 17 00:00:00 2001 From: Aotrix <9aotrix@protonmail.com> Date: Sat, 31 Jan 2026 21:08:13 +0100 Subject: added conditional breakpoint shortcut and virtual text --- lua/aotrix/plugins/lsp.lua | 32 ++++++++++++++------------------ lua/aotrix/plugins/nvim_dap.lua | 17 ++++++++++++----- 2 files changed, 26 insertions(+), 23 deletions(-) (limited to 'lua/aotrix') diff --git a/lua/aotrix/plugins/lsp.lua b/lua/aotrix/plugins/lsp.lua index c55aa0b..484f289 100644 --- a/lua/aotrix/plugins/lsp.lua +++ b/lua/aotrix/plugins/lsp.lua @@ -6,7 +6,7 @@ return { config = function() require("mason").setup() require("mason-lspconfig").setup({ - ensure_installed = { "cmake", "lua_ls" } + ensure_installed = {"cmake", "lua_ls"} }) vim.lsp.config["clangd"] = { cmd = { @@ -14,25 +14,20 @@ return { "--header-insertion=iwyu", "--completion-style=detailed", "--function-arg-placeholders", "--fallback-style=llvm" }, - root_markers = { { "CMakeLists.txt", - "Makefile", - "configure.ac", - "configure.in", - "config.h.in", - "meson.build", - "meson_options.txt", - "build.ninja" }, - { "compile_commands.json", "compile_flags.txt" }, - { ".git" } }, - filetypes = { "cpp", "hpp", "c", "h" }, + root_markers = { + { + "CMakeLists.txt", "Makefile", "configure.ac", + "configure.in", "config.h.in", "meson.build", + "meson_options.txt", "build.ninja" + }, {"compile_commands.json", "compile_flags.txt"}, {".git"} + }, + filetypes = {"cpp", "hpp", "c", "h"}, capabilities = { - offsetEncoding = { "utf-16" }, + offsetEncoding = {"utf-16"}, textDocument = { - semanticTokens = { - multilineTokenSupport = true, - }, - completion = { completionItem = { snippetSupport = true } } + semanticTokens = {multilineTokenSupport = true}, + completion = {completionItem = {snippetSupport = true}} } }, init_options = { @@ -41,12 +36,13 @@ return { clangdFileStatus = true } } + vim.diagnostic.config({virtual_text = true}) vim.keymap.set("n", "o", "LspClangdSwitchSourceHeader") vim.lsp.config["cmake"] = {} vim.lsp.config["lua_ls"] = { - settings = { completion = { callSnippet = 'Replace' } } + settings = {completion = {callSnippet = 'Replace'}} } vim.lsp.enable("clangd") diff --git a/lua/aotrix/plugins/nvim_dap.lua b/lua/aotrix/plugins/nvim_dap.lua index ab10f40..115e044 100644 --- a/lua/aotrix/plugins/nvim_dap.lua +++ b/lua/aotrix/plugins/nvim_dap.lua @@ -13,7 +13,7 @@ return { require("dapui").setup() require("nvim-dap-virtual-text").setup() require("mason").setup() - require("mason-nvim-dap").setup({ ensure_installed = { "codelldb" } }) + require("mason-nvim-dap").setup({ensure_installed = {"codelldb"}}) dap.adapters.codelldb = { type = "executable", @@ -27,7 +27,7 @@ return { request = "launch", program = function() return vim.fn.input('Path to executable: ', - vim.fn.getcwd() .. '/', 'file') + vim.fn.getcwd() .. '/', 'file') end, cwd = '${workspaceFolder}', stopOnEntry = false @@ -44,13 +44,20 @@ return { end vim.keymap.set("n", "b", - function() require("dap").toggle_breakpoint() end) + function() require("dap").toggle_breakpoint() end) vim.keymap.set("n", "gb", - function() require("dap").run_to_cursor() end) + function() require("dap").run_to_cursor() end) + vim.keymap.set("n", "B", function() + local condition = vim.fn.input("Conditional breakpoint: ") + require("dap").toggle_breakpoint(condition) + end) -- Eval var under cursor vim.keymap.set("n", "?", function() - require("dapui").eval(nil, { enter = true }) + require("dapui").eval(nil, {enter = true}) end) + -- Use mT to start a new session + vim.keymap.set("n", "mT", function() require("dap").continue() end) + -- Use F1 to continue vim.keymap.set("n", "", function() require("dap").continue() end) vim.keymap.set("n", "", function() require("dap").step_over() end) vim.keymap.set("n", "", function() require("dap").step_into() end) -- cgit v1.2.3