diff options
| author | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-02 14:54:21 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-02 14:54:28 +0100 |
| commit | f1478b23dc185f8fe091c61044eefe3aacbe6ff2 (patch) | |
| tree | 7a1fb36fa3bccf95c40e542275e88c4c1354adbc /config/nvim/lua | |
| parent | af1960cdb38fd5607810cc0bf9775dbe37032d85 (diff) | |
Update neovim DAP config
Diffstat (limited to 'config/nvim/lua')
| -rw-r--r-- | config/nvim/lua/dap_config.lua | 195 | ||||
| -rw-r--r-- | config/nvim/lua/plugins.lua | 5 |
2 files changed, 111 insertions, 89 deletions
diff --git a/config/nvim/lua/dap_config.lua b/config/nvim/lua/dap_config.lua index 9d9fa64..c8f8d32 100644 --- a/config/nvim/lua/dap_config.lua +++ b/config/nvim/lua/dap_config.lua @@ -1,120 +1,143 @@ local dap = require('dap') require("dapui").setup() +dap.set_log_level('ERROR') + +-- ---------------------------------------------------------------------------- +-- Keymaps +-- ---------------------------------------------------------------------------- + vim.keymap.set('n', '<leader>d', function() - require("dapui").toggle() + require('dapui').toggle() +end) +vim.keymap.set('n', '<space>b', function() + require('dap').toggle_breakpoint() +end) +vim.keymap.set('n', '<space>d', function() + require'dap'.continue() end) -require("dap-vscode-js").setup({ - debugger_path = os.getenv('HOME') .. '/projects/vendor/vscode-js-debug/out/adapter.bundle.js', - adapters = { 'pwa-node', 'node-terminal' }, -}) +-- ---------------------------------------------------------------------------- +-- LLDB (Rust / C++ / C) +-- ---------------------------------------------------------------------------- -require("dap").adapters["pwa-node"] = { - type = 'server', - host = 'localhost', - port = '${port}', - executable = { - command = 'node', - -- 💀 Make sure to update this path to point to your installation - args = { os.getenv('HOME') .. '/projects/vendor/vscode-js-debug/src/dapDebugServer.ts', '${port}' }, - } +dap.adapters.lldb = { + type = 'executable', + command = '/Applications/Xcode.app/Contents/Developer/usr/bin/lldb-dap', -- adjust as needed, must be absolute path + name = 'lldb' } -dap.configurations.javascript = { - { - type = "pwa-node", - request = "attach", - name = "Attach", - cwd = "${workspaceFolder}", - }, +dap.configurations.rust = { { - type = "pwa-node", - request = "launch", - name = "Launch file", - program = "${file}", - cwd = "${workspaceFolder}", - }, + name = "Launch", + type = "lldb", + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = false, + args = {}, + } } + +-- ---------------------------------------------------------------------------- +-- Javascript +-- ---------------------------------------------------------------------------- + dap.adapters.firefox = { type = 'executable', command = 'node', - args = {os.getenv('HOME') .. '/projects/tools/vscode-firefox-debug/dist/adapter.bundle.js'}, + args = {os.getenv('HOME') .. '/projects/vendor/vscode-firefox-debug/dist/adapter.bundle.js'}, +} + +dap.adapters['pwa-node'] = { + type = 'server', + host = 'localhost', + port = '${port}', + executable = { + command = 'node', + args = { os.getenv('HOME') .. '/projects/vendor/js-debug/src/dapDebugServer.js', '${port}' }, + } } + dap.configurations.typescript = { { name = 'Debug with Firefox', type = 'firefox', request = 'launch', reAttach = true, - url = 'http://localhost:3000', + url = function() + return vim.fn.input('URL to open: ', 'http://127.0.0.1') + end, webRoot = '${workspaceFolder}', - firefoxExecutable = '/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox' + firefoxExecutable = '/Applications/Firefox.app/Contents/MacOS/firefox' } } dap.configurations.typescriptreact = { { - name = 'Debug with Firefox', - type = 'firefox', - request = 'launch', - reAttach = true, - url = 'http://localhost:3000', - webRoot = '${workspaceFolder}', - firefoxExecutable = '/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox' + name = 'Debug with Firefox', + type = 'firefox', + request = 'launch', + reAttach = true, + url = function() + return vim.fn.input('URL to open: ', 'http://127.0.0.1') + end, + webRoot = '${workspaceFolder}', + firefoxExecutable = '/Applications/Firefox.app/Contents/MacOS/firefox' } } -dap.adapters.python = function(cb, config) - if config.request == 'attach' then - ---@diagnostic disable-next-line: undefined-field - local port = (config.connect or config).port - ---@diagnostic disable-next-line: undefined-field - local host = (config.connect or config).host or '127.0.0.1' - cb({ - type = 'server', - port = assert(port, '`connect.port` is required for a python `attach` configuration'), - host = host, - options = { - source_filetype = 'python', - }, - }) - else - cb({ - type = 'executable', - command = os.getenv('HOME') .. '/.asdf/shims/python', - args = { '-m', 'debugpy.adapter' }, - options = { - source_filetype = 'python', - }, - }) - end -end - -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 +dap.configurations.javascript = { + { + name = 'Debug with Firefox', + type = 'firefox', + request = 'launch', + reAttach = true, + url = function() + return vim.fn.input('URL to open: ', 'http://127.0.0.1') + end, + webRoot = '${workspaceFolder}', + firefoxExecutable = '/Applications/Firefox.app/Contents/MacOS/firefox', + pathMappings = { + -- Zola + { + url = 'http://127.0.0.1:1111', + path = '${workspaceFolder}/static' + }, - 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 os.getenv('HOME') .. '/.asdf/shims/python' - end - end; - }, + -- Static pages or pages built with `page` should work out of the box. + } + }, + { + type = "pwa-node", + request = "launch", + name = "Launch (node)", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = "${workspaceFolder}", + console = "integratedTerminal", + }, + { + type = "pwa-node", + request = "attach", + name = "Attach (node)", + cwd = "${workspaceFolder}", + console = "integratedTerminal", + }, + { + type = "pwa-node", + request = "attach", + address = "localhost", + port = 9229, + name = "Attach (docker/node)", + cwd = "${workspaceFolder}", + remoteRoot = "/app", + sourceMaps = true, + console = "integratedTerminal", + } } diff --git a/config/nvim/lua/plugins.lua b/config/nvim/lua/plugins.lua index 5876b51..758c5fe 100644 --- a/config/nvim/lua/plugins.lua +++ b/config/nvim/lua/plugins.lua @@ -59,13 +59,12 @@ require('lazy').setup({ --'Debugging { - 'mfussenegger/nvim-dap', + 'rcarriga/nvim-dap-ui', dependencies = { + 'mfussenegger/nvim-dap', 'nvim-neotest/nvim-nio' } }, - 'rcarriga/nvim-dap-ui', - 'mxsdev/nvim-dap-vscode-js', -- Editing 'RRethy/nvim-treesitter-endwise', |