feat: add nvimdots
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
-- https://github.com/mfussenegger/nvim-dap/wiki/C-C---Rust-(via--codelldb)
|
||||
return function()
|
||||
local dap = require("dap")
|
||||
local utils = require("modules.utils.dap")
|
||||
local is_windows = require("core.global").is_windows
|
||||
|
||||
dap.adapters.codelldb = {
|
||||
type = "server",
|
||||
port = "${port}",
|
||||
executable = {
|
||||
command = vim.fn.exepath("codelldb"), -- Find codelldb on $PATH
|
||||
args = { "--port", "${port}" },
|
||||
detached = is_windows and false or true,
|
||||
},
|
||||
}
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = "Debug",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = utils.input_exec_path(),
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = false,
|
||||
terminal = "integrated",
|
||||
},
|
||||
{
|
||||
name = "Debug (with args)",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = utils.input_exec_path(),
|
||||
args = utils.input_args(),
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = false,
|
||||
terminal = "integrated",
|
||||
},
|
||||
{
|
||||
name = "Attach to a running process",
|
||||
type = "codelldb",
|
||||
request = "attach",
|
||||
program = utils.input_exec_path(),
|
||||
stopOnEntry = false,
|
||||
waitFor = true,
|
||||
},
|
||||
}
|
||||
dap.configurations.cpp = dap.configurations.c
|
||||
dap.configurations.rust = dap.configurations.c
|
||||
end
|
||||
@@ -0,0 +1,100 @@
|
||||
-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#go
|
||||
-- https://github.com/golang/vscode-go/blob/master/docs/debugging.md
|
||||
return function()
|
||||
local dap = require("dap")
|
||||
local utils = require("modules.utils.dap")
|
||||
|
||||
if not require("mason-registry").is_installed("go-debug-adapter") then
|
||||
vim.notify(
|
||||
"Automatically installing `go-debug-adapter` for go debugging",
|
||||
vim.log.levels.INFO,
|
||||
{ title = "nvim-dap" }
|
||||
)
|
||||
|
||||
local go_dbg = require("mason-registry").get_package("go-debug-adapter")
|
||||
go_dbg:install():once(
|
||||
"closed",
|
||||
vim.schedule_wrap(function()
|
||||
if go_dbg:is_installed() then
|
||||
vim.notify("Successfully installed `go-debug-adapter`", vim.log.levels.INFO, { title = "nvim-dap" })
|
||||
end
|
||||
end)
|
||||
)
|
||||
end
|
||||
|
||||
dap.adapters.go = {
|
||||
type = "executable",
|
||||
command = "node",
|
||||
args = {
|
||||
require("mason-registry").get_package("go-debug-adapter"):get_install_path()
|
||||
.. "/extension/dist/debugAdapter.js",
|
||||
},
|
||||
}
|
||||
dap.configurations.go = {
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug (file)",
|
||||
request = "launch",
|
||||
cwd = "${workspaceFolder}",
|
||||
program = utils.input_file_path(),
|
||||
console = "integratedTerminal",
|
||||
dlvToolPath = vim.fn.exepath("dlv"),
|
||||
showLog = true,
|
||||
showRegisters = true,
|
||||
stopOnEntry = false,
|
||||
},
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug (file with args)",
|
||||
request = "launch",
|
||||
cwd = "${workspaceFolder}",
|
||||
program = utils.input_file_path(),
|
||||
args = utils.input_args(),
|
||||
console = "integratedTerminal",
|
||||
dlvToolPath = vim.fn.exepath("dlv"),
|
||||
showLog = true,
|
||||
showRegisters = true,
|
||||
stopOnEntry = false,
|
||||
},
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug (executable)",
|
||||
request = "launch",
|
||||
cwd = "${workspaceFolder}",
|
||||
program = utils.input_exec_path(),
|
||||
args = utils.input_args(),
|
||||
console = "integratedTerminal",
|
||||
dlvToolPath = vim.fn.exepath("dlv"),
|
||||
mode = "exec",
|
||||
showLog = true,
|
||||
showRegisters = true,
|
||||
stopOnEntry = false,
|
||||
},
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug (test file)",
|
||||
request = "launch",
|
||||
cwd = "${workspaceFolder}",
|
||||
program = utils.input_file_path(),
|
||||
console = "integratedTerminal",
|
||||
dlvToolPath = vim.fn.exepath("dlv"),
|
||||
mode = "test",
|
||||
showLog = true,
|
||||
showRegisters = true,
|
||||
stopOnEntry = false,
|
||||
},
|
||||
{
|
||||
type = "go",
|
||||
name = "Debug (using go.mod)",
|
||||
request = "launch",
|
||||
cwd = "${workspaceFolder}",
|
||||
program = "./${relativeFileDirname}",
|
||||
console = "integratedTerminal",
|
||||
dlvToolPath = vim.fn.exepath("dlv"),
|
||||
mode = "test",
|
||||
showLog = true,
|
||||
showRegisters = true,
|
||||
stopOnEntry = false,
|
||||
},
|
||||
}
|
||||
end
|
||||
@@ -0,0 +1,36 @@
|
||||
-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#ccrust-via-lldb-vscode
|
||||
return function()
|
||||
local dap = require("dap")
|
||||
local utils = require("modules.utils.dap")
|
||||
|
||||
dap.adapters.lldb = {
|
||||
type = "executable",
|
||||
command = vim.fn.exepath("lldb-vscode"), -- Find lldb-vscode on $PATH
|
||||
}
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = "Launch",
|
||||
type = "lldb",
|
||||
request = "launch",
|
||||
program = utils.input_exec_path(),
|
||||
cwd = "${workspaceFolder}",
|
||||
args = utils.input_args(),
|
||||
env = utils.get_env(),
|
||||
|
||||
-- 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,
|
||||
},
|
||||
}
|
||||
|
||||
dap.configurations.cpp = dap.configurations.c
|
||||
dap.configurations.rust = dap.configurations.c
|
||||
end
|
||||
@@ -0,0 +1,74 @@
|
||||
-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#python
|
||||
-- https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings
|
||||
return function()
|
||||
local dap = require("dap")
|
||||
local utils = require("modules.utils.dap")
|
||||
local is_windows = require("core.global").is_windows
|
||||
local debugpy_root = require("mason-registry").get_package("debugpy"):get_install_path()
|
||||
|
||||
dap.adapters.python = function(callback, config)
|
||||
if config.request == "attach" then
|
||||
local port = (config.connect or config).port
|
||||
local host = (config.connect or config).host or "127.0.0.1"
|
||||
callback({
|
||||
type = "server",
|
||||
port = assert(port, "`connect.port` is required for a python `attach` configuration"),
|
||||
host = host,
|
||||
options = { source_filetype = "python" },
|
||||
})
|
||||
else
|
||||
callback({
|
||||
type = "executable",
|
||||
command = is_windows and debugpy_root .. "/venv/Scripts/pythonw.exe"
|
||||
or debugpy_root .. "/venv/bin/python",
|
||||
args = { "-m", "debugpy.adapter" },
|
||||
options = { source_filetype = "python" },
|
||||
})
|
||||
end
|
||||
end
|
||||
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 = "Debug",
|
||||
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
|
||||
console = "integratedTerminal",
|
||||
program = utils.input_file_path(),
|
||||
pythonPath = function()
|
||||
local venv = vim.env.CONDA_PREFIX
|
||||
if venv then
|
||||
return is_windows and venv .. "/Scripts/pythonw.exe" or venv .. "/bin/python"
|
||||
else
|
||||
return is_windows and "pythonw.exe" or "python3"
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
-- NOTE: This setting is for people using venv
|
||||
type = "python",
|
||||
request = "launch",
|
||||
name = "Debug (using venv)",
|
||||
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
|
||||
console = "integratedTerminal",
|
||||
program = utils.input_file_path(),
|
||||
pythonPath = function()
|
||||
-- Prefer the venv that is defined by the designated environment variable.
|
||||
local cwd, venv = vim.fn.getcwd(), os.getenv("VIRTUAL_ENV")
|
||||
local python = venv and (is_windows and venv .. "/Scripts/pythonw.exe" or venv .. "/bin/python") or ""
|
||||
if vim.fn.executable(python) == 1 then
|
||||
return python
|
||||
end
|
||||
|
||||
-- Otherwise, fall back to check if there are any local venvs available.
|
||||
venv = vim.fn.isdirectory(cwd .. "/venv") == 1 and cwd .. "/venv" or cwd .. "/.venv"
|
||||
python = is_windows and venv .. "/Scripts/pythonw.exe" or venv .. "/bin/python"
|
||||
if vim.fn.executable(python) == 1 then
|
||||
return python
|
||||
else
|
||||
return is_windows and "pythonw.exe" or "python3"
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
||||
end
|
||||
Reference in New Issue
Block a user