mirror of
https://github.com/kristoferssolo/SoloVim.git
synced 2025-10-21 20:10:41 +00:00
204 lines
5.2 KiB
Lua
204 lines
5.2 KiB
Lua
local status_mason_dap_ok, mason_dap = pcall(require, "mason-nvim-dap")
|
|
if not status_mason_dap_ok then
|
|
return
|
|
end
|
|
|
|
local dap_status_ok, dap = pcall(require, "dap")
|
|
if not dap_status_ok then
|
|
return
|
|
end
|
|
|
|
local dap_ui_status_ok, dapui = pcall(require, "dapui")
|
|
if not dap_ui_status_ok then
|
|
return
|
|
end
|
|
|
|
local dap_install_status_ok, dap_install = pcall(require, "dap-install")
|
|
if not dap_install_status_ok then
|
|
return
|
|
end
|
|
|
|
mason_dap.setup({
|
|
automatic_installation = true,
|
|
automatic_setup = true,
|
|
})
|
|
-- add other configs here
|
|
|
|
dapui.setup({
|
|
layouts = {
|
|
{
|
|
elements = {
|
|
"scopes",
|
|
"breakpoints",
|
|
"stacs",
|
|
"watches",
|
|
},
|
|
size = 40,
|
|
position = "left",
|
|
},
|
|
{
|
|
elements = {
|
|
"repl",
|
|
"console",
|
|
},
|
|
size = 10,
|
|
position = "bottom",
|
|
},
|
|
},
|
|
-- sidebar = {
|
|
-- elements = {
|
|
-- {
|
|
-- id = "scopes",
|
|
-- size = 0.25, -- Can be float or integer > 1
|
|
-- },
|
|
-- { id = "breakpoints", size = 0.25 },
|
|
-- },
|
|
-- size = 40,
|
|
-- position = "right", -- Can be "left", "right", "top", "bottom"
|
|
-- },
|
|
-- tray = {
|
|
-- elements = {},
|
|
-- },
|
|
})
|
|
|
|
vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" })
|
|
|
|
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
|
|
|
|
-- Python
|
|
dap.adapters.python = {
|
|
type = "executable",
|
|
-- command = vim.fn.stdpath("data") .. "/mason/packages/debugpy/venv/bin/python",
|
|
-- args = { "-m", "debugpy.adapter" },
|
|
command = vim.fn.stdpath("data") .. "/mason/bin/debugpy-adapter",
|
|
}
|
|
dap.configurations.python = {
|
|
{
|
|
-- The first three options are required by nvim-dap
|
|
type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python`
|
|
request = "launch",
|
|
name = "Launch file",
|
|
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
|
|
|
|
program = "${file}", -- This configuration will launch the current file if used.
|
|
pythonPath = function()
|
|
-- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
|
|
-- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
|
|
-- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
|
|
local cwd = vim.fn.getcwd()
|
|
if vim.fn.executable(cwd .. "/venv/bin/python") == 1 then
|
|
return cwd .. "/venv/bin/python"
|
|
elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then
|
|
return cwd .. "/.venv/bin/python"
|
|
else
|
|
return "/usr/bin/python"
|
|
end
|
|
end,
|
|
},
|
|
}
|
|
|
|
-- C/C++/Rust
|
|
dap.adapters.lldb = {
|
|
type = "executable",
|
|
command = vim.fn.stdpath("data") .. "/mason/packages/codelldb/extension/adapter/codelldb", -- adjust as needed, must be absolute path
|
|
name = "lldb",
|
|
}
|
|
dap.configurations.cpp = {
|
|
{
|
|
name = "Launch",
|
|
type = "lldb",
|
|
request = "launch",
|
|
program = function()
|
|
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
stopOnEntry = false,
|
|
args = {},
|
|
|
|
-- 💀
|
|
-- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting:
|
|
--
|
|
-- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
|
|
--
|
|
-- Otherwise you might get the following error:
|
|
--
|
|
-- Error on launch: Failed to attach to the target process
|
|
--
|
|
-- But you should be aware of the implications:
|
|
-- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html
|
|
-- runInTerminal = false,
|
|
},
|
|
}
|
|
|
|
-- If you want to use this for Rust and C, add something like this:
|
|
|
|
dap.configurations.c = dap.configurations.cpp
|
|
dap.configurations.rust = dap.configurations.cpp
|
|
|
|
-- JavaScript
|
|
dap.adapters.firefox = {
|
|
type = "executable",
|
|
command = "node",
|
|
args = { vim.fn.stdpath("data") .. "/mason/packages/firefox-debug-adapter/dist/adapter.bundle.js" },
|
|
}
|
|
dap.configurations.typescript = {
|
|
{
|
|
name = "Debug with Librewolf",
|
|
type = "firefox",
|
|
request = "launch",
|
|
reAttach = true,
|
|
url = "http://localhost:3000",
|
|
webRoot = "${workspaceFolder}",
|
|
firefoxExecutable = "/usr/bin/librewolf",
|
|
},
|
|
}
|
|
dap.configurations.javascript = {
|
|
{
|
|
name = "Debug with Librewolf",
|
|
type = "firefox",
|
|
request = "launch",
|
|
reAttach = true,
|
|
url = "http://localhost:3000",
|
|
webRoot = "${workspaceFolder}",
|
|
firefoxExecutable = "/usr/bin/librewolf",
|
|
},
|
|
}
|
|
|
|
-- Bash
|
|
dap.adapters.bashdb = {
|
|
type = "executable",
|
|
command = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/bash-debug-adapter",
|
|
name = "bashdb",
|
|
}
|
|
dap.configurations.sh = {
|
|
{
|
|
type = "bashdb",
|
|
request = "launch",
|
|
name = "Launch file",
|
|
showDebugOutput = true,
|
|
pathBashdb = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/extension/bashdb_dir/bashdb",
|
|
pathBashdbLib = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/extension/bashdb_dir",
|
|
trace = true,
|
|
file = "${file}",
|
|
program = "${file}",
|
|
cwd = "${workspaceFolder}",
|
|
pathCat = "bat",
|
|
pathBash = "/bin/zash",
|
|
pathMkfifo = "mkfifo",
|
|
pathPkill = "pkill",
|
|
args = {},
|
|
env = {},
|
|
terminalKind = "integrated",
|
|
},
|
|
}
|