aboutsummaryrefslogtreecommitdiff
path: root/dot_config/nvim/lua/plugins/dap.lua
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config/nvim/lua/plugins/dap.lua')
-rw-r--r--dot_config/nvim/lua/plugins/dap.lua77
1 files changed, 77 insertions, 0 deletions
diff --git a/dot_config/nvim/lua/plugins/dap.lua b/dot_config/nvim/lua/plugins/dap.lua
new file mode 100644
index 0000000..6d63dfa
--- /dev/null
+++ b/dot_config/nvim/lua/plugins/dap.lua
@@ -0,0 +1,77 @@
+return {
+ "mfussenegger/nvim-dap",
+ event = "VeryLazy",
+ dependencies = {
+ "rcarriga/nvim-dap-ui",
+ "nvim-neotest/nvim-nio",
+ "jay-babu/mason-nvim-dap.nvim",
+ "theHamsta/nvim-dap-virtual-text",
+ },
+ config = function()
+ local mason_dap = require("mason-nvim-dap")
+ local dap = require("dap")
+ local ui = require("dapui")
+ local dap_virtual_text = require("nvim-dap-virtual-text")
+
+ -- Dap Virtual Text
+ dap_virtual_text.setup()
+
+ mason_dap.setup({
+ ensure_installed = { "python" },
+ automatic_installation = true,
+ handlers = {
+ function(config)
+ require("mason-nvim-dap").default_setup(config)
+ end,
+ },
+ })
+
+ -- Configurations
+ dap.configurations = {
+ python = {
+ {
+ -- The first three options are required by nvim-dap
+ type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python`
+ request = "launch",
+ name = "Launch file",
+
+ -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
+
+ program = "${file}", -- This configuration will launch the current file if used.
+ pythonPath = function()
+ -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
+ -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
+ -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
+ 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,
+ },
+ },
+ }
+
+ -- Dap UI
+
+ ui.setup()
+
+ vim.fn.sign_define("DapBreakpoint", { text = "🐞" })
+
+ dap.listeners.before.attach.dapui_config = function()
+ ui.open()
+ end
+ dap.listeners.before.launch.dapui_config = function()
+ ui.open()
+ end
+ dap.listeners.before.event_terminated.dapui_config = function()
+ ui.close()
+ end
+ dap.listeners.before.event_exited.dapui_config = function()
+ ui.close()
+ end
+ end
+}