diff --git a/nvim/lua/user/plugins/ide.lua b/nvim/lua/user/plugins/ide.lua index 805ddc1..b2da6a6 100644 --- a/nvim/lua/user/plugins/ide.lua +++ b/nvim/lua/user/plugins/ide.lua @@ -4,6 +4,7 @@ return { { import = "user.plugins.ide.autocomplete" }, { import = "user.plugins.ide.formatting" }, { import = "user.plugins.ide.test" }, + { import = "user.plugins.ide.debugger" }, -- Linting { 'mfussenegger/nvim-lint', diff --git a/nvim/lua/user/plugins/ide/debugger.lua b/nvim/lua/user/plugins/ide/debugger.lua new file mode 100644 index 0000000..4d08b8e --- /dev/null +++ b/nvim/lua/user/plugins/ide/debugger.lua @@ -0,0 +1,82 @@ +return { + { + "mfussenegger/nvim-dap", + dependencies = { + { + "rcarriga/nvim-dap-ui", + dependencies = { + "nvim-neotest/nvim-nio" + } + } + }, + config = function () + local icons = require('user.icons') + local dap = require('dap') + local dapui = require("dapui") + + dap.set_log_level('TRACE') + dapui.setup() + + -- Signs + vim.fn.sign_define('DapBreakpoint', {text=icons.debug.breakpoint, texthl='DapBreakpoint'}) + vim.fn.sign_define('DapBreakpointCondition', {text=icons.debug.breakpointCondition, texthl='DapBreakpointCondition'}) + vim.fn.sign_define('DapBreakpointRejected', {text=icons.debug.rejected, texthl='DapBreakpointRejected'}) + vim.fn.sign_define('DapLogPoint', {text=icons.debug.logPoint, texthl='DapLogPoint'}) + vim.fn.sign_define('DapStopped', {text=icons.debug.stopped, texthl='DapStopped'}) + + vim.keymap.set("n", "Dr", dap.run_last, { silent = true }) + vim.keymap.set("n", "Dc", dap.continue, { silent = true }) + vim.keymap.set("n", "Do", dap.step_over, { silent = true }) + vim.keymap.set("n", "Di", dap.step_into, { silent = true }) + vim.keymap.set("n", "Db", dap.step_out, { silent = true }) + vim.keymap.set("n", "Dt", dap.toggle_breakpoint, { silent = true }) + + dap.listeners.before.attach.dapui_config = function() + dapui.open() + end + dap.listeners.before.launch.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 + + dap.adapters.php = { + type = 'executable', + command = 'node', + args = { '/home/pnx/vscode-php-debug/out/phpDebug.js' } + } + + dap.configurations.php = { + { + name = "PHP: Listen for Xdebug", + port = 9003, + request = "launch", + type = "php", + breakpoints = { + exception = { + Notice = false, + Warning = false, + Error = false, + Exception = false, + ["*"] = false, + }, + }, + pathMappings = { + ["/app"] = "${workspaceFolder}" + } + }, + } + end + }, + { + "rcarriga/nvim-dap-ui", + dependencies = { + "mfussenegger/nvim-dap", + "nvim-neotest/nvim-nio" + } + } +}