nvim: big dap changes:

go: launch dlv manually and add a mapping to set the port (dsp)
python: get rid of it for now
lldb: include lldb for rust and c
This commit is contained in:
2023-07-08 15:20:42 +03:00
parent 020e412354
commit 1ae4ccab75
7 changed files with 78 additions and 55 deletions

View File

@ -111,9 +111,6 @@ end)
vim.keymap.set("n", "<leader>dq", function()
require("dap").close()
end)
vim.keymap.set("n", "<leader>du", function()
require("dapui").toggle()
end)
vim.keymap.set("n", "<leader>dv", "<cmd>Telescope dap variables<CR>")
vim.keymap.set("n", "<leader>dh", "<cmd>Telescope dap commands<CR>")
vim.keymap.set("n", "<leader>dp", "<cmd>Telescope dap list_breakpoints<CR>")

View File

@ -104,20 +104,6 @@ require("packer").startup(function()
"nvim-telescope/telescope-dap.nvim",
after = "nvim-dap",
})
use({
"rcarriga/nvim-dap-ui",
after = "nvim-dap",
config = function()
require("plugins.dapui")
end,
})
use({
"leoluz/nvim-dap-go",
after = "nvim-dap",
config = function()
require("plugins.dap-go")
end,
})
use({
"theHamsta/nvim-dap-virtual-text",
after = "nvim-dap",

View File

@ -1 +0,0 @@
require("dap-go").setup()

View File

@ -1,37 +1,7 @@
local dap = require("dap")
--
-- python
--
dap.adapters.python = {
type = "executable",
command = "python",
args = { "-m", "debugpy.adapter" },
}
dap.configurations.python = {
{
type = "python",
request = "launch",
name = "Launch file",
program = "${file}",
pythonPath = function()
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
-- lldb
--
dap.adapters.lldb = {
@ -40,18 +10,66 @@ dap.adapters.lldb = {
name = "lldb",
}
dap.configurations.c = {
local lldb = {
{
name = "Launch",
type = "lldb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
return vim.fn.input("path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
args = {},
runInTerminal = false,
runInTerminal = true,
},
}
dap.configurations.c = lldb
dap.configurations.rust = lldb
--
-- go
--
vim.keymap.set("n", "<leader>dsp", function()
local port = vim.fn.input("enter port for delve: ")
dap.adapters.go.port = port
print("now run 'dlv dap -l 127.0.0.1:" .. port .. "'")
end)
dap.adapters.go = {
type = "server",
host = "127.0.0.1",
port = 38000,
}
dap.configurations.go = {
{
type = "go",
name = "Debug",
request = "launch",
program = "${file}",
},
{
type = "go",
name = "Debug Package",
request = "launch",
program = "${fileDirname}",
},
{
type = "go",
name = "Debug test",
request = "launch",
mode = "test",
program = "${file}",
},
{
type = "go",
name = "Debug test (go.mod)",
request = "launch",
mode = "test",
program = "./${relativeFileDirname}",
},
}

View File

@ -1 +0,0 @@
require("dapui").setup()

View File

@ -15,3 +15,25 @@ lsp.gopls.setup({})
lsp.clangd.setup({})
lsp.texlab.setup({})
lsp.rust_analyzer.setup({})
lsp.sumneko_lua.setup({
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
})

View File

@ -16,6 +16,10 @@ wk.register({
o = "Step Out",
p = "List Breakpoints",
q = "Stop",
s = {
name = "Set DAP Variables",
p = "Delve Port",
},
u = "Toggle UI",
v = "Show Variables",
},
@ -68,13 +72,11 @@ wk.register({
X = "Quit All Without Saving",
c = "Toggle All Terminal",
f = "File Manager",
f = "File Manager",
h = "Left Split",
j = "Down Split",
k = "Up Split",
l = "Right Split",
q = "Quit",
s = "Save",
x = "Quit Without Saving",
}, { prefix = "<leader>" })
wk.setup({})