From abe6a88fa75c92c31161ead8ebfc1c9f0e72996d Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Fri, 8 Dec 2023 11:43:05 -0800 Subject: [PATCH] Add dap --- install-language-servers.sh | 9 ++++++ neovim/lua/plugins.lua | 60 +++++++++++++++++++++++++++++++++++++ neovim/lua/plugins/lsp.lua | 7 ++++- 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/install-language-servers.sh b/install-language-servers.sh index 4b54f91..6d5a727 100755 --- a/install-language-servers.sh +++ b/install-language-servers.sh @@ -216,12 +216,21 @@ function install_fixers() { echo "" } +## Debuggers +function install_debuggers() { + # Python + if want_lang python ;then + maybe_run pip3 install --user --upgrade debugpy + fi +} + function main() { maybe_run pip3 install --user --upgrade release-gitter install_language_servers install_linters install_fixers + install_debuggers echo "" echo "DONE" diff --git a/neovim/lua/plugins.lua b/neovim/lua/plugins.lua index 7f826c5..d45850a 100644 --- a/neovim/lua/plugins.lua +++ b/neovim/lua/plugins.lua @@ -243,6 +243,61 @@ use({ }), }) +-- Debug adapter protocol +use({ + "https://github.com/mfussenegger/nvim-dap", + -- TODO: Move to lazy.nvim and allow it to load this only when the required debuggers are loaded + ft = { "python", "rust" }, +}) + +use({ + "https://github.com/rcarriga/nvim-dap-ui", + requires = { "https://github.com/mfussenegger/nvim-dap" }, + after = "nvim-dap", + config = function() + require("dapui").setup({ + icons = { + expanded = "-", + collapsed = "+", + current_frame = ">", + }, + controls = { + icons = { + disconnect = "disconnect", + pause = "pause", + play = "play", + run_last = "last", + step_back = "back", + step_into = "into", + step_out = "out", + step_over = "over", + terminate = "term", + }, + }, + }) + local dap, dapui = require("dap"), require("dapui") + 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 + end, +}) + +use({ + "https://github.com/mfussenegger/nvim-dap-python", + requires = { "https://github.com/mfussenegger/nvim-dap" }, + after = "nvim-dap", + config = function() + require("dap-python").setup() + end, + ft = "python", +}) + -- Install language servers use({ "https://github.com/williamboman/mason.nvim", @@ -263,7 +318,12 @@ use({ -- Rust analyzer use({ "https://github.com/simrat39/rust-tools.nvim", + after = "nvim-dap", disable = vim.fn.has("nvim-0.7.0") ~= 1, + -- TODO: After switching to lazy, with better dependency ordering, can remove the after + config = function() + require("dap") + end, }) -- Better display of lsp diagnostics diff --git a/neovim/lua/plugins/lsp.lua b/neovim/lua/plugins/lsp.lua index 8160f31..456bd06 100644 --- a/neovim/lua/plugins/lsp.lua +++ b/neovim/lua/plugins/lsp.lua @@ -331,7 +331,12 @@ function M.config_lsp() -- Configure neovim dev for when sumneko_lua is installed utils.try_require("neodev", function(neodev) - neodev.setup({}) + local config = {} + if utils.can_require("dapui") then + config.plugins = { "nvim-dap-ui" } + config.types = true + end + neodev.setup(config) end) -- Auto setup mason installed servers