Dap updates
This commit is contained in:
parent
b2233c485a
commit
cc64429d00
4 changed files with 70 additions and 30 deletions
|
@ -204,6 +204,7 @@ return require("lazy").setup({
|
||||||
"hrsh7th/cmp-nvim-lua", -- Nvim-Lua source for nvim-cmp
|
"hrsh7th/cmp-nvim-lua", -- Nvim-Lua source for nvim-cmp
|
||||||
"hrsh7th/cmp-omni", -- omnifunc source for nvim-cmp
|
"hrsh7th/cmp-omni", -- omnifunc source for nvim-cmp
|
||||||
"hrsh7th/nvim-cmp", -- completion integration
|
"hrsh7th/nvim-cmp", -- completion integration
|
||||||
|
"rcarriga/cmp-dap", -- DAP nvim-cmp
|
||||||
"mhartington/formatter.nvim", -- formatting support
|
"mhartington/formatter.nvim", -- formatting support
|
||||||
"mfussenegger/nvim-lint", -- linting support
|
"mfussenegger/nvim-lint", -- linting support
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,9 @@ local cmp = require("cmp")
|
||||||
local luasnip = require("luasnip")
|
local luasnip = require("luasnip")
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
|
enabled = function()
|
||||||
|
return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" or require("cmp_dap").is_dap_buffer()
|
||||||
|
end,
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
require("luasnip").lsp_expand(args.body)
|
require("luasnip").lsp_expand(args.body)
|
||||||
|
@ -79,5 +82,11 @@ cmp.setup.filetype("ledger", {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
cmp.setup.filetype({ "dap-repl", "dapui_watches", "dapui_hover" }, {
|
||||||
|
sources = {
|
||||||
|
{ name = "dap" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||||
|
|
|
@ -94,6 +94,9 @@ require("flutter-tools").setup({
|
||||||
|
|
||||||
-- Rust tools
|
-- Rust tools
|
||||||
vim.g.rustaceanvim = vim.tbl_deep_extend("force", vim.g.rustaceanvim or {}, {
|
vim.g.rustaceanvim = vim.tbl_deep_extend("force", vim.g.rustaceanvim or {}, {
|
||||||
|
dap = {
|
||||||
|
configuration = false,
|
||||||
|
},
|
||||||
server = vim.tbl_extend("force", common_config, {
|
server = vim.tbl_extend("force", common_config, {
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
common_config.on_attach(client, bufnr)
|
common_config.on_attach(client, bufnr)
|
||||||
|
|
|
@ -76,13 +76,43 @@ local function args_input()
|
||||||
return vim.split(vim.fn.input("Args: "), " ")
|
return vim.split(vim.fn.input("Args: "), " ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function server_input()
|
||||||
|
return vim.fn.input("Server to connect to: ")
|
||||||
|
end
|
||||||
|
|
||||||
-- Additional servers
|
-- Additional servers
|
||||||
dap.adapters.lldb = {
|
dap.adapters.lldb = {
|
||||||
type = "executable",
|
type = "executable",
|
||||||
command = "codelldb",
|
command = "lldb",
|
||||||
name = "lldb",
|
name = "lldb",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dap.adapters.rustlldb = {
|
||||||
|
type = "executable",
|
||||||
|
command = "rust-lldb",
|
||||||
|
name = "rustlldb",
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.adapters.gdb = {
|
||||||
|
name = "gdb",
|
||||||
|
type = "executable",
|
||||||
|
command = "gdb",
|
||||||
|
args = { "--quiet", "--interpreter=dap", "--eval-command", "set print pretty on" },
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.adapters.rustgdb = {
|
||||||
|
name = "rustgdb",
|
||||||
|
type = "executable",
|
||||||
|
command = "rust-gdb",
|
||||||
|
args = { "--quiet", "--interpreter=dap", "--eval-command", "set print pretty on" },
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.adapters.codelldb = {
|
||||||
|
type = "executable",
|
||||||
|
command = "codelldb",
|
||||||
|
name = "codelldb",
|
||||||
|
}
|
||||||
|
|
||||||
dap.adapters.nlua = function(callback, config)
|
dap.adapters.nlua = function(callback, config)
|
||||||
callback({ type = "server", host = config.host, port = config.port })
|
callback({ type = "server", host = config.host, port = config.port })
|
||||||
end
|
end
|
||||||
|
@ -90,65 +120,62 @@ end
|
||||||
dap.configurations.cpp = {
|
dap.configurations.cpp = {
|
||||||
{
|
{
|
||||||
name = "Launch",
|
name = "Launch",
|
||||||
type = "lldb",
|
type = "gdb",
|
||||||
request = "launch",
|
request = "launch",
|
||||||
program = executable_input,
|
program = executable_input,
|
||||||
cwd = "${workspaceFolder}",
|
cwd = "${workspaceFolder}",
|
||||||
stopOnEntry = false,
|
stopAtBeginningOfMainSubprogram = 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 use `runInTerminal = true` and resize the terminal window,
|
|
||||||
-- lldb-vscode will receive a `SIGWINCH` signal which can cause problems
|
|
||||||
-- To avoid that uncomment the following option
|
|
||||||
-- See https://github.com/mfussenegger/nvim-dap/issues/236#issuecomment-1066306073
|
|
||||||
postRunCommands = { "process handle -p true -s false -n false SIGWINCH" },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "Launch with args",
|
name = "Launch with args",
|
||||||
type = "lldb",
|
type = "gdb",
|
||||||
request = "launch",
|
request = "launch",
|
||||||
program = executable_input,
|
program = executable_input,
|
||||||
cwd = "${workspaceFolder}",
|
cwd = "${workspaceFolder}",
|
||||||
stopOnEntry = false,
|
|
||||||
args = args_input,
|
args = args_input,
|
||||||
runInTerminal = false,
|
|
||||||
postRunCommands = { "process handle -p true -s false -n false SIGWINCH" },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "Attach to process",
|
name = "Attach to process",
|
||||||
type = "lldb",
|
type = "gdb",
|
||||||
request = "attach",
|
request = "attach",
|
||||||
|
program = executable_input,
|
||||||
pid = require("dap.utils").pick_process,
|
pid = require("dap.utils").pick_process,
|
||||||
args = {},
|
args = {},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "Attach to PID",
|
name = "Attach to PID",
|
||||||
type = "lldb",
|
type = "gdb",
|
||||||
request = "attach",
|
request = "attach",
|
||||||
|
program = executable_input,
|
||||||
pid = function()
|
pid = function()
|
||||||
return tonumber(vim.fn.input("PID: "))
|
return tonumber(vim.fn.input("PID: "))
|
||||||
end,
|
end,
|
||||||
args = {},
|
args = {},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name = "Attach to gdbserver",
|
||||||
|
type = "gdb",
|
||||||
|
request = "attach",
|
||||||
|
target = server_input,
|
||||||
|
program = executable_input,
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
dap.configurations.c = dap.configurations.cpp
|
dap.configurations.c = dap.configurations.cpp
|
||||||
dap.configurations.rust = dap.configurations.cpp
|
|
||||||
dap.configurations.zig = dap.configurations.cpp
|
dap.configurations.zig = dap.configurations.cpp
|
||||||
|
|
||||||
|
local rust_config = {}
|
||||||
|
for _, item in ipairs(dap.configurations.cpp) do
|
||||||
|
table.insert(
|
||||||
|
rust_config,
|
||||||
|
vim.tbl_extend("force", item, {
|
||||||
|
type = "rustgdb",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
end
|
||||||
|
dap.configurations.rust = rust_config
|
||||||
|
|
||||||
dap.configurations.lua = {
|
dap.configurations.lua = {
|
||||||
{
|
{
|
||||||
type = "nlua",
|
type = "nlua",
|
||||||
|
|
Loading…
Add table
Reference in a new issue