From ca5f5a6a0cd7c108cd5e809f3c199232dc7f7718 Mon Sep 17 00:00:00 2001 From: mequidis Date: Mon, 30 May 2022 11:14:56 +0300 Subject: [PATCH] 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 --- .config/nvim/lua/mappings.lua | 3 - .config/nvim/lua/plugins.lua | 14 ----- .config/nvim/lua/plugins/dap-go.lua | 1 - .config/nvim/lua/plugins/dap.lua | 86 ++++++++++++++++----------- .config/nvim/lua/plugins/dapui.lua | 1 - .config/nvim/lua/plugins/lsp.lua | 22 +++++++ .config/nvim/lua/plugins/whichkey.lua | 6 +- 7 files changed, 78 insertions(+), 55 deletions(-) delete mode 100644 .config/nvim/lua/plugins/dap-go.lua delete mode 100644 .config/nvim/lua/plugins/dapui.lua diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua index 825b8a7..ba274de 100644 --- a/.config/nvim/lua/mappings.lua +++ b/.config/nvim/lua/mappings.lua @@ -111,9 +111,6 @@ end) vim.keymap.set("n", "dq", function() require("dap").close() end) -vim.keymap.set("n", "du", function() - require("dapui").toggle() -end) vim.keymap.set("n", "dv", "Telescope dap variables") vim.keymap.set("n", "dh", "Telescope dap commands") vim.keymap.set("n", "dp", "Telescope dap list_breakpoints") diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 0aca508..61df761 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -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", diff --git a/.config/nvim/lua/plugins/dap-go.lua b/.config/nvim/lua/plugins/dap-go.lua deleted file mode 100644 index 1ec449a..0000000 --- a/.config/nvim/lua/plugins/dap-go.lua +++ /dev/null @@ -1 +0,0 @@ -require("dap-go").setup() diff --git a/.config/nvim/lua/plugins/dap.lua b/.config/nvim/lua/plugins/dap.lua index bf54675..79b8fc0 100644 --- a/.config/nvim/lua/plugins/dap.lua +++ b/.config/nvim/lua/plugins/dap.lua @@ -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", "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}", }, } diff --git a/.config/nvim/lua/plugins/dapui.lua b/.config/nvim/lua/plugins/dapui.lua deleted file mode 100644 index 648a3e8..0000000 --- a/.config/nvim/lua/plugins/dapui.lua +++ /dev/null @@ -1 +0,0 @@ -require("dapui").setup() diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index e3d482a..ef0f805 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -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, + }, + }, + }, +}) diff --git a/.config/nvim/lua/plugins/whichkey.lua b/.config/nvim/lua/plugins/whichkey.lua index 792772a..59dc199 100644 --- a/.config/nvim/lua/plugins/whichkey.lua +++ b/.config/nvim/lua/plugins/whichkey.lua @@ -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 = "" }) wk.setup({})