Update dap.lua config

main
Ensar Sarajčić 2022-05-03 18:56:58 +02:00
parent c622dd6206
commit f23e301124
2 changed files with 59 additions and 9 deletions

View File

@ -0,0 +1,15 @@
-------------------------------------------------------------------------------
-- - Vim-test and general testing config -
-------------------------------------------------------------------------------
-- make test commands execute using dispatch.vim
vim.g["test#strategy"] = "dispatch"
vim.g["test#csharp#runner"] = "dotnettest"
-- Map test running commands
local opts = { silent = true }
vim.keymap.set("n", "<Leader>tn", ":TestNearest<CR>", opts)
vim.keymap.set("n", "<Leader>tf", ":TestFile<CR>", opts)
vim.keymap.set("n", "<Leader>ts", ":TestSuite<CR>", opts)
vim.keymap.set("n", "<Leader>tl", ":TestLast<CR>", opts)
vim.keymap.set("n", "<Leader>tg", ":TestVisit<CR>", opts)

View File

@ -20,6 +20,14 @@ vim.keymap.set("n", "<leader>dc", dap.continue)
vim.keymap.set("n", "<leader>dso", dap.step_over) vim.keymap.set("n", "<leader>dso", dap.step_over)
vim.keymap.set("n", "<leader>dsi", dap.step_into) vim.keymap.set("n", "<leader>dsi", dap.step_into)
-- Neovim Lua debugging
vim.api.nvim_create_user_command("NeovimDebugStart", function()
require("osv").launch()
end, {})
vim.api.nvim_create_user_command("NeovimDebugThis", function()
require("osv").run_this()
end, {})
-- Nvim DAP UI -- Nvim DAP UI
local dapui = require("dapui") local dapui = require("dapui")
dapui.setup() dapui.setup()
@ -54,6 +62,15 @@ dap.listeners.after["event_terminated"]["me"] = function()
keymap_restore = {} keymap_restore = {}
end end
-- dap utils
local function executable_input()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end
local function args_input()
return vim.split(vim.fn.input("Args: "), " ")
end
-- Additional servers -- Additional servers
dap.adapters.lldb = { dap.adapters.lldb = {
type = "executable", type = "executable",
@ -61,14 +78,16 @@ dap.adapters.lldb = {
name = "lldb", name = "lldb",
} }
dap.adapters.nlua = function(callback, config)
callback({ type = "server", host = config.host, port = config.port })
end
dap.configurations.cpp = { dap.configurations.cpp = {
{ {
name = "Launch", name = "Launch",
type = "lldb", type = "lldb",
request = "launch", request = "launch",
program = function() program = executable_input,
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}", cwd = "${workspaceFolder}",
stopOnEntry = false, stopOnEntry = false,
args = {}, args = {},
@ -96,14 +115,10 @@ dap.configurations.cpp = {
name = "Launch with args", name = "Launch with args",
type = "lldb", type = "lldb",
request = "launch", request = "launch",
program = function() program = executable_input,
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}", cwd = "${workspaceFolder}",
stopOnEntry = false, stopOnEntry = false,
args = function() args = args_input,
return vim.split(vim.fn.input("Args: "), " ")
end,
runInTerminal = false, runInTerminal = false,
postRunCommands = { "process handle -p true -s false -n false SIGWINCH" }, postRunCommands = { "process handle -p true -s false -n false SIGWINCH" },
}, },
@ -129,6 +144,26 @@ dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp dap.configurations.rust = dap.configurations.cpp
dap.configurations.zig = dap.configurations.cpp dap.configurations.zig = dap.configurations.cpp
dap.configurations.lua = {
{
type = "nlua",
request = "attach",
name = "Attach to running Neovim instance",
host = function()
local value = vim.fn.input("Host [127.0.0.1]: ")
if value ~= "" then
return value
end
return "127.0.0.1"
end,
port = function()
local val = tonumber(vim.fn.input("Port: "))
assert(val, "Please provide a port number")
return val
end,
},
}
dap.listeners.after.event_initialized["dapui_config"] = function() dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open() dapui.open()
end end