From 68421c46154e326410ea651deb64060aa9f01b61 Mon Sep 17 00:00:00 2001 From: David Ibia Date: Wed, 3 Jan 2024 01:13:50 +0100 Subject: [PATCH] feat(dap.lua): add configuration for dap and dap-ui plugins to enable debugging features in Neovim feat(lsp-config.lua): configure python lsp using pylsp to provide language server capabilities for Python files refactor(magma.lua): remove magma plugin configuration as it is no longer used feat(mason.lua): add configuration for mason and mason-nvim-dap plugins to enable package management and debugging features in Neovim refactor(init.lua): set maplocalleader to "\\" for easier keybindings refactor(remap.lua): remove setting mapleader to " " as it is no longer needed, add keybinding for toggling file explorer using NvimTreeToggle command --- lazy-lock.json | 4 ++++ lua/absolute/after/dap.lua | 28 +++++++++++++++++++++++++ lua/absolute/after/lsp-config.lua | 7 +++++++ lua/absolute/after/magma.lua | 0 lua/absolute/after/mason.lua | 6 ++++++ lua/absolute/core/init.lua | 1 + lua/absolute/plugins/dap.lua | 13 ++++++++++++ lua/absolute/plugins/magma.lua.disabled | 7 ------- lua/absolute/plugins/mason.lua | 7 +++++++ lua/absolute/remap.lua | 2 -- 10 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 lua/absolute/after/dap.lua delete mode 100644 lua/absolute/after/magma.lua create mode 100644 lua/absolute/plugins/dap.lua delete mode 100644 lua/absolute/plugins/magma.lua.disabled diff --git a/lazy-lock.json b/lazy-lock.json index 11c851a..0f51f30 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -17,10 +17,14 @@ "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, "magma-nvim": { "branch": "main", "commit": "ff3deba8a879806a51c005e50782130246143d06" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "9e82ded0515186edd4f69e4ce6b1a5f1b55b47e9" }, "mason.nvim": { "branch": "main", "commit": "a09da6ac634926a299dd439da08bdb547a8ca011" }, "mini.nvim": { "branch": "main", "commit": "b5645ac6eefce8e7af9d7dd4e5e296a81cba8a10" }, "nightfly": { "branch": "master", "commit": "90d85c8a094266122fb1fd173e7bcc0cd0efdd49" }, "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, + "nvim-dap": { "branch": "master", "commit": "f0dca670fa059eb89dda8869a6310c804241345c" }, + "nvim-dap-python": { "branch": "master", "commit": "091e4ae00a12085f9ed4200a3cd04af7179b8a23" }, + "nvim-dap-ui": { "branch": "master", "commit": "34160a7ce6072ef332f350ae1d4a6a501daf0159" }, "nvim-lsp-file-operations": { "branch": "master", "commit": "8e7223e138590c1bd9d86d3de810e65939d8b12f" }, "nvim-lspconfig": { "branch": "master", "commit": "ce0e625df61be77abe1340fbc9afe9ad39b31dd8" }, "nvim-tree.lua": { "branch": "master", "commit": "f1b3e6a7eb92da492bd693257367d9256839ed3d" }, diff --git a/lua/absolute/after/dap.lua b/lua/absolute/after/dap.lua new file mode 100644 index 0000000..0487757 --- /dev/null +++ b/lua/absolute/after/dap.lua @@ -0,0 +1,28 @@ +local dap = require("dap") +local dapui = require("dapui") +local dap_python = require("dap-python") + +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() +end +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() +end +dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() +end + + +local path = "~/.local/share/nvim/mason/packages/debugpy/venv/bin/python" +dap_python.setup(path) + +-- Setup Mappings +local opts = { noremap = true, silent = true } + +opts.desc = "Toggle breakpoint" +vim.keymap.set("n", "db", " DapToggleBreakpoint", opts) + +opts.desc = "Debug Python Run" +vim.keymap.set("n", "dpr", function() + dap_python.test_method() +end, opts) diff --git a/lua/absolute/after/lsp-config.lua b/lua/absolute/after/lsp-config.lua index 6a3c5e3..aaab7d3 100644 --- a/lua/absolute/after/lsp-config.lua +++ b/lua/absolute/after/lsp-config.lua @@ -117,6 +117,13 @@ lspconfig["pyright"].setup({ on_attach = on_attach, }) +-- configure python lsp +lspconfig["pylsp"].setup({ + capabilities = capabilities, + on_attach = on_attach, +}) + + -- configure docker server lspconfig["dockerls"].setup({ capabilities = capabilities, diff --git a/lua/absolute/after/magma.lua b/lua/absolute/after/magma.lua deleted file mode 100644 index e69de29..0000000 diff --git a/lua/absolute/after/mason.lua b/lua/absolute/after/mason.lua index b9c71b4..780359b 100644 --- a/lua/absolute/after/mason.lua +++ b/lua/absolute/after/mason.lua @@ -14,3 +14,9 @@ require("mason-lspconfig").setup({ }, automatic_installation = true, }) +require("mason-nvim-dap").setup({ + ensure_installed = { + "debugpy", -- python + }, + automatic_installation = true, +}) diff --git a/lua/absolute/core/init.lua b/lua/absolute/core/init.lua index b3a10e8..e6261f9 100644 --- a/lua/absolute/core/init.lua +++ b/lua/absolute/core/init.lua @@ -31,3 +31,4 @@ vim.opt.updatetime = 50 vim.opt.colorcolumn = "" vim.g.mapleader = " " +vim.g.maplocalleader = "\\" diff --git a/lua/absolute/plugins/dap.lua b/lua/absolute/plugins/dap.lua new file mode 100644 index 0000000..b01c236 --- /dev/null +++ b/lua/absolute/plugins/dap.lua @@ -0,0 +1,13 @@ +return { + "mfussenegger/nvim-dap", + dependencies = { + -- "theHamsta/nvim-dap-virtual-text", + "rcarriga/nvim-dap-ui", + -- "nvim-telescope/telescope-dap.nvim", + { "mfussenegger/nvim-dap-python", ft = "python", dependencies = { "mfussenegger/nvim-dap" } }, + -- "Pocco81/DAPInstall.nvim" + }, + config = function() + require("absolute.after.dap") + end +} diff --git a/lua/absolute/plugins/magma.lua.disabled b/lua/absolute/plugins/magma.lua.disabled deleted file mode 100644 index 9f46e03..0000000 --- a/lua/absolute/plugins/magma.lua.disabled +++ /dev/null @@ -1,7 +0,0 @@ -return { - "dccsillag/magma-nvim", - config = function() - vim.cmd([[ UpdateRemotePlugins ]]) - require("absolute.after.magma") - end -} diff --git a/lua/absolute/plugins/mason.lua b/lua/absolute/plugins/mason.lua index 8351d8b..58c7445 100644 --- a/lua/absolute/plugins/mason.lua +++ b/lua/absolute/plugins/mason.lua @@ -2,6 +2,13 @@ return { 'williamboman/mason.nvim', dependencies = { 'williamboman/mason-lspconfig.nvim', + { + "jay-babu/mason-nvim-dap.nvim", + dependencies = { + "mfussenegger/nvim-dap", + + } + } }, config = function() require("absolute.after.mason") diff --git a/lua/absolute/remap.lua b/lua/absolute/remap.lua index 7026717..f61cfe4 100644 --- a/lua/absolute/remap.lua +++ b/lua/absolute/remap.lua @@ -1,5 +1,3 @@ -vim.g.mapleader = " " - vim.keymap.set("n", "\\", "NvimTreeToggle") -- toggle file explorer