From: Alexander Goussas Date: Sun, 22 Jun 2025 04:23:51 +0000 (-0500) Subject: nvim: add dap configuration X-Git-Url: http://git.frustrated-labs.net/?a=commitdiff_plain;h=9bf5c389372c46465f2dd91d3bb40860c8c9b090;p=dotfiles.git nvim: add dap configuration --- diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 05b4d8f..4c41e3b 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -12,17 +12,17 @@ require("autocmds") local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = "https://github.com/folke/lazy.nvim.git" - local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) - if vim.v.shell_error ~= 0 then - vim.api.nvim_echo({ - { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, - { out, "WarningMsg" }, - { "\nPress any key to exit..." }, - }, true, {}) - vim.fn.getchar() - os.exit(1) - end + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end end vim.opt.rtp:prepend(lazypath) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 1112054..85eb925 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -3,21 +3,27 @@ "copilot.vim": { "branch": "release", "commit": "3955014c503b0cd7b30bc56c86c56c0736ca0951" }, "ghcid": { "branch": "master", "commit": "b7dc5c4ee640b6c8137ecfd0a2b50df278015221" }, "gitsigns.nvim": { "branch": "main", "commit": "731b581428ec6c1ccb451b95190ebbc6d7006db7" }, - "haskell-tools.nvim": { "branch": "master", "commit": "9a9830b5b303f77e57c64db18d15436ec089954e" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-dap": { "branch": "master", "commit": "2edd6375692d9ac1053d50acfe415c1eb2ba92d0" }, + "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, + "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, "nvim-grey": { "branch": "main", "commit": "585d77c010047061c4ca512a2095a2ac710af5e6" }, "nvim-lspconfig": { "branch": "master", "commit": "7ad4a11cc5742774877c529fcfb2702f7caf75e4" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" }, "nvim-tree.lua": { "branch": "master", "commit": "d87b41ca537e2131622d48a6c25ccf2fbe0e5d62" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-treesitter-endwise": { "branch": "master", "commit": "d6cbb83307d516ec076d17c9a33d704ef626ee8c" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, + "one-small-step-for-vimkind": { "branch": "main", "commit": "d9f832598e14f3b206b06f5738d02cebede65269" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "vim-stylish-haskell": { "branch": "master", "commit": "60a59fd767956c40372b5aeab2d68a0a953ebb2b" }, + "vscode-js-debug": { "branch": "main", "commit": "0b5e0dade997b3c702a98e1f58989afcb30612d6" }, "workspaces.nvim": { "branch": "master", "commit": "55a1eb6f5b72e07ee8333898254e113e927180ca" } } diff --git a/nvim/.config/nvim/lua/plugins/dap.lua b/nvim/.config/nvim/lua/plugins/dap.lua new file mode 100644 index 0000000..30f1c43 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/dap.lua @@ -0,0 +1,155 @@ +-- Debugging. +return { + { + 'mfussenegger/nvim-dap', + dependencies = { + -- Fancy UI for the debugger + { "nvim-neotest/nvim-nio" }, + { + 'rcarriga/nvim-dap-ui', + keys = { + { + 'de', + function() + -- Calling this twice to open and jump into the window. + require('dapui').eval() + require('dapui').eval() + end, + desc = 'Evaluate expression', + }, + }, + opts = { + floating = { border = 'rounded' }, + layouts = { + { + elements = { + { id = 'stacks', size = 0.30 }, + { id = 'breakpoints', size = 0.20 }, + { id = 'scopes', size = 0.50 }, + }, + position = 'left', + size = 40, + }, + }, + }, + }, + -- Virtual text. + { + 'theHamsta/nvim-dap-virtual-text', + opts = { virt_text_pos = 'eol' }, + }, + -- JS/TS debugging. + { + 'mxsdev/nvim-dap-vscode-js', + opts = { + debugger_path = vim.fn.stdpath 'data' .. '/lazy/vscode-js-debug', + adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' }, + }, + }, + { + 'microsoft/vscode-js-debug', + build = 'npm i && npm run compile vsDebugServerBundle && rm -rf out && mv -f dist out', + }, + -- Lua adapter. + { + 'jbyuki/one-small-step-for-vimkind', + keys = { + { + 'dl', + function() + require('osv').launch { port = 8086 } + end, + desc = 'Launch Lua adapter', + }, + }, + }, + }, + keys = { + { + 'db', + function() + require('dap').toggle_breakpoint() + end, + desc = 'Toggle breakpoint', + }, + { + 'dB', + 'FzfLua dap_breakpoints', + desc = 'List breakpoints', + }, + { + 'dc', + function() + require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, + desc = 'Breakpoint condition', + }, + { + '', + function() + require('dap').continue() + end, + desc = 'Continue', + }, + { + '', + function() + require('dap').step_over() + end, + desc = 'Step over', + }, + { + '', + function() + require('dap').step_into() + end, + desc = 'Step into', + }, + { + '', + function() + require('dap').step_out() + end, + desc = 'Step Out', + }, + }, + config = function() + local dap = require 'dap' + local dapui = require 'dapui' + + -- Automatically open the UI when a new debug session is created. + 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 + + -- Lua configurations. + dap.adapters.nlua = function(callback, config) + callback { type = 'server', host = config.host or '127.0.0.1', port = config.port or 8086 } + end + dap.configurations['lua'] = { + { + type = 'nlua', + request = 'attach', + name = 'Attach to running Neovim instance', + }, + } + + -- C configurations. + dap.adapters.codelldb = { + type = 'server', + host = 'localhost', + port = '${port}', + executable = { + command = 'codelldb', + args = { '--port', '${port}' }, + }, + } + end, + }, +}