Setup debug adapters for codelldb, debugpy and gopls. Also remove

nvim-dap-profiles :( Apparently there is a way to do the same thing
using launch.json built into dap, much better than my solution.
This commit is contained in:
Martin Larsson 2025-01-11 19:08:40 +01:00
parent b7796e9a5e
commit 472208ea95
8 changed files with 95 additions and 7 deletions

View file

@ -29,7 +29,10 @@ require("terminal")
require("window_management").setup()
-- Set configs for servers and enable them in the Neovim LSP Client
require("lsp")
require("lsp/setup")
-- Set configs for nvim-dap so we can debug
require("dap/setup")
-- See ":help vim.highlight.on_yank()"
setup_yank_highlight()

View file

@ -0,0 +1,8 @@
return {
type = "server",
port = "${port}",
executable = {
command = vim.fn.exepath("codelldb"), -- Update with your codelldb binary path
args = { "--port", "${port}" },
},
}

View file

@ -0,0 +1,45 @@
local utils = require("utils")
local dap = require("dap")
--[[
.vscode/launch.json:
----------------------------
{
"version": "0.2.0",
"configurations": [
{
"type": "name_of_adapter",
"request": "launch/attach",
"name": "Friendly name",
"program": "${workspaceFolder}/path/to/executable",
"cwd": "${workspaceFolder}",
"args": [],
"stopOnEntry": false,
"environment": []
}
]
}
----------------------------
]]
local dir_path = "dap/adapters"
utils.foreach(utils.get_file_names_in_dir(dir_path, "*.lua", true), function(adapter)
dap.adapters[adapter] = require(dir_path .. "/" .. adapter)
end)
-- Do not define default fallbacks until I have a better way of handling a default selected configuration.
-- I never want to be prompted for a configuration, we should have ae serialized active config which is always run unless changed.
-- -- Define configurations
-- dap.configurations.cpp = {
-- {
-- name = "Launch File",
-- type = "codelldb",
-- request = "launch",
-- program = function()
-- return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
-- end,
-- cwd = "${workspaceFolder}",
-- stopOnEntry = false,
-- args = {},
-- },
-- }

View file

@ -0,0 +1,21 @@
return {
cmd = { "pyright-langserver", "--stdio" },
filetypes = { "python", "py" },
root_markers = {
"pyproject.toml",
"setup.py",
"setup.cfg",
"requirements.txt",
"Pipfile",
"pyrightconfig.json",
},
settings = {
python = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
diagnosticMode = "openFilesOnly",
},
},
},
}

View file

@ -26,6 +26,10 @@ return {
-- CMake
"cmake-language-server",
"cmakelang",
-- Python
"debugpy",
"pyright",
},
})
end

View file

@ -5,24 +5,30 @@ return {
"mfussenegger/nvim-dap",
dependencies = {
"rcarriga/nvim-dap-ui",
-- Special adapters
"leoluz/nvim-dap-go",
"mfussenegger/nvim-dap-python",
{ "nvim-neotest/nvim-nio", lazy = true },
"LiadOz/nvim-dap-repl-highlights",
"theHamsta/nvim-dap-virtual-text",
"Weissle/persistent-breakpoints.nvim",
{
"LarssonMartin1998/nvim-dap-profiles",
opts = {},
},
"leoluz/nvim-dap-go",
},
config = function()
local dap = require("dap")
local dapui = require("dapui")
dapui.setup()
-- Special adapters
require("dap-go").setup()
require("dap-python").setup("python3")
-- Special adapters
require("dap.ext.vscode").load_launchjs()
require("persistent-breakpoints").setup {
load_breakpoints_event = { "BufReadPost" }
}
require("dap-go").setup()
local stepping_keymaps = {
n = {

View file

@ -46,6 +46,7 @@ return {
"regex",
"dap_repl",
"muttrc",
"python",
},
sync_install = false,
-- This can be updated to a list of languages instead of defaulting to true