diff --git a/term/.config/nvim/lua/plugins/debug-jsts.lua b/term/.config/nvim/lua/plugins/debug-jsts.lua new file mode 100644 index 0000000..59181b6 --- /dev/null +++ b/term/.config/nvim/lua/plugins/debug-jsts.lua @@ -0,0 +1,72 @@ +---@diagnostic disable: missing-fields +return { + { + "mxsdev/nvim-dap-vscode-js", + dependencies = { + "mfussenegger/nvim-dap", + { + "microsoft/vscode-js-debug", + version = "1.x", + build = "npm ci --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out", + }, + }, + config = function() + local dap = require("dap") + require("dap-vscode-js").setup({ + debugger_path = vim.fn.stdpath("data") .. "/lazy/vscode-js-debug", + adapters = { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" }, + }) + + for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact", "vue" }) do + dap.configurations[language] = { + { + type = "pwa-node", + request = "launch", + name = "Launch file", + program = "${file}", + cwd = "${workspaceFolder}", + }, + { + type = "pwa-node", + request = "attach", + name = "Attach", + processId = require("dap.utils").pick_process, + cwd = "${workspaceFolder}", + }, + { + type = "pwa-node", + request = "launch", + name = "Debug Jest Tests", + runtimeExecutable = "node", + runtimeArgs = { + "./node_modules/jest/bin/jest.js", + "--runInBand", + }, + rootPath = "${workspaceFolder}", + cwd = "${workspaceFolder}", + console = "integratedTerminal", + internalConsoleOptions = "neverOpen", + }, + { + type = "pwa-chrome", + request = "launch", + name = "Launch Chrome", + url = "http://localhost:3000", + webRoot = "${workspaceFolder}", + }, + { + type = "pwa-chrome", + request = "launch", + name = "Launch Chrome (Vue dev server)", + url = function() + local port = vim.fn.input("Port (default 8080): ", "8080") + return "http://localhost:" .. port + end, + webRoot = "${workspaceFolder}", + sourceMaps = true, + }, + } + end + end, + }, +} diff --git a/term/.config/nvim/lua/plugins/debug-python.lua b/term/.config/nvim/lua/plugins/debug-python.lua new file mode 100644 index 0000000..43bb73c --- /dev/null +++ b/term/.config/nvim/lua/plugins/debug-python.lua @@ -0,0 +1,69 @@ +---@diagnostic disable: missing-fields +return { + { + "mfussenegger/nvim-dap-python", + dependencies = "mfussenegger/nvim-dap", + config = function() + local dap = require("dap") + require("dap-python").setup() + + dap.configurations.python = { + { + type = "python", + request = "launch", + name = "Launch file", + program = "${file}", + pythonPath = function() + return vim.fn.exepath("python3") or "python" + end, + }, + { + type = "python", + request = "launch", + name = "Debug current file (integrated terminal)", + program = "${file}", + console = "integratedTerminal", + pythonPath = function() + return vim.fn.exepath("python3") or "python" + end, + }, + { + type = "python", + request = "launch", + name = "Debug with arguments", + program = "${file}", + args = function() + local args = vim.fn.input("Args: ", ""):split(" ") + return args + end, + console = "integratedTerminal", + pythonPath = function() + return vim.fn.exepath("python3") or "python" + end, + }, + { + type = "python", + request = "launch", + name = "Debug test_api.py", + module = "unittest", + args = { "test.test_api", "-v" }, + cwd = "${workspaceFolder}", + pythonPath = function() + return vim.fn.exepath("python3") or "python" + end, + }, + { + type = "python", + request = "launch", + name = "Debug all tests", + module = "unittest", + args = { "discover", "-s", "test", "-v" }, + cwd = "${workspaceFolder}", + pythonPath = function() + return vim.fn.exepath("python3") or "python" + end, + }, + } + end, + }, +} diff --git a/term/.config/nvim/lua/plugins/debug-ui.lua b/term/.config/nvim/lua/plugins/debug-ui.lua new file mode 100644 index 0000000..5ec8b36 --- /dev/null +++ b/term/.config/nvim/lua/plugins/debug-ui.lua @@ -0,0 +1,80 @@ +---@diagnostic disable: missing-fields +return { + { + "mfussenegger/nvim-dap", + }, + { + "rcarriga/nvim-dap-ui", + dependencies = "nvim-neotest/nvim-nio", + event = "VeryLazy", + config = function() + local dap = require("dap") + local dapui = require("dapui") + + dapui.setup({ + icons = { expanded = "▾", collapsed = "▸", current_frame = "▸" }, + mappings = { + expand = { "", "<2-LeftMouse>" }, + open = "o", + remove = "d", + edit = "e", + repl = "r", + toggle = "t", + }, + expand_lines = vim.fn.has("nvim-0.7") == 1, + layouts = { + { + elements = { + { id = "scopes", size = 0.25 }, + { id = "breakpoints", size = 0.25 }, + { id = "stacks", size = 0.25 }, + { id = "watches", size = 0.25 }, + }, + size = 0.25, + position = "right", + }, + { + elements = { + { id = "repl", size = 0.5 }, + { id = "console", size = 0.5 }, + }, + position = "bottom", + size = 0.25, + }, + }, + floating = { + max_height = nil, + max_width = nil, + border = "rounded", + mappings = { + close = { "q", "" }, + }, + }, + windows = { indent = 1 }, + }) + + 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 + + vim.keymap.set("n", "", dap.toggle_breakpoint, { desc = "Toggle breakpoint" }) + vim.keymap.set("n", "", dap.continue, { desc = "Continue" }) + vim.keymap.set("n", "", dap.step_over, { desc = "Step over" }) + vim.keymap.set("n", "", dap.step_into, { desc = "Step into" }) + vim.keymap.set("n", "", dap.step_out, { desc = "Step out" }) + vim.keymap.set("n", "", dap.repl.open, { desc = "Open REPL" }) + vim.keymap.set("n", "", dap.run_last, { desc = "Run last debug config" }) + vim.keymap.set("n", "", dapui.toggle, { desc = "Toggle DAP UI" }) + end, + }, + { + "theHamsta/nvim-dap-virtual-text", + dependencies = "mfussenegger/nvim-dap", + }, +} diff --git a/term/.config/nvim/lua/plugins/debugging.lua b/term/.config/nvim/lua/plugins/debugging.lua deleted file mode 100644 index 3d87b09..0000000 --- a/term/.config/nvim/lua/plugins/debugging.lua +++ /dev/null @@ -1,210 +0,0 @@ ----@diagnostic disable: missing-fields -return { - { - "mfussenegger/nvim-dap", - }, - { - "rcarriga/nvim-dap-ui", - dependencies = "nvim-neotest/nvim-nio", - }, - { - "theHamsta/nvim-dap-virtual-text", - dependencies = "mfussenegger/nvim-dap", - }, - { - "mxsdev/nvim-dap-vscode-js", - dependencies = { - "mfussenegger/nvim-dap", - { - "microsoft/vscode-js-debug", - version = "1.x", - build = "npm ci --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out", - }, - }, - }, - { - "mfussenegger/nvim-dap-python", - dependencies = "mfussenegger/nvim-dap", - config = function() - local dap = require("dap") - local dapui = require("dapui") - require("dap-python").setup() - - -- JavaScript/TypeScript debugging - require("dap-vscode-js").setup({ - debugger_path = vim.fn.stdpath("data") .. "/lazy/vscode-js-debug", - adapters = { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" }, - }) - - for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact", "vue" }) do - dap.configurations[language] = { - { - type = "pwa-node", - request = "launch", - name = "Launch file", - program = "${file}", - cwd = "${workspaceFolder}", - }, - { - type = "pwa-node", - request = "attach", - name = "Attach", - processId = require("dap.utils").pick_process, - cwd = "${workspaceFolder}", - }, - { - type = "pwa-node", - request = "launch", - name = "Debug Jest Tests", - runtimeExecutable = "node", - runtimeArgs = { - "./node_modules/jest/bin/jest.js", - "--runInBand", - }, - rootPath = "${workspaceFolder}", - cwd = "${workspaceFolder}", - console = "integratedTerminal", - internalConsoleOptions = "neverOpen", - }, - { - type = "pwa-chrome", - request = "launch", - name = "Launch Chrome", - url = "http://localhost:3000", - webRoot = "${workspaceFolder}", - }, - { - type = "pwa-chrome", - request = "launch", - name = "Launch Chrome (Vue dev server)", - url = function() - local port = vim.fn.input("Port (default 8080): ", "8080") - return "http://localhost:" .. port - end, - webRoot = "${workspaceFolder}", - sourceMaps = true, - }, - } - end - - dapui.setup({ - icons = { expanded = "▾", collapsed = "▸", current_frame = "▸" }, - mappings = { - expand = { "", "<2-LeftMouse>" }, - open = "o", - remove = "d", - edit = "e", - repl = "r", - toggle = "t", - }, - expand_lines = vim.fn.has("nvim-0.7") == 1, - layouts = { - { - elements = { - { id = "scopes", size = 0.25 }, - { id = "breakpoints", size = 0.25 }, - { id = "stacks", size = 0.25 }, - { id = "watches", size = 0.25 }, - }, - size = 0.25, - position = "right", - }, - { - elements = { - { id = "repl", size = 0.5 }, - { id = "console", size = 0.5 }, - }, - position = "bottom", - size = 0.25, - }, - }, - floating = { - max_height = nil, - max_width = nil, - border = "rounded", - mappings = { - close = { "q", "" }, - }, - }, - windows = { indent = 1 }, - }) - - 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 - - dap.configurations.python = { - { - type = "python", - request = "launch", - name = "Launch file", - program = "${file}", - pythonPath = function() - return vim.fn.exepath("python3") or "python" - end, - }, - { - type = "python", - request = "launch", - name = "Debug current file (integrated terminal)", - program = "${file}", - console = "integratedTerminal", - pythonPath = function() - return vim.fn.exepath("python3") or "python" - end, - }, - { - type = "python", - request = "launch", - name = "Debug with arguments", - program = "${file}", - args = function() - local args = vim.fn.input("Args: ", ""):split(" ") - return args - end, - console = "integratedTerminal", - pythonPath = function() - return vim.fn.exepath("python3") or "python" - end, - }, - { - type = "python", - request = "launch", - name = "Debug test_api.py", - module = "unittest", - args = { "test.test_api", "-v" }, - cwd = "${workspaceFolder}", - pythonPath = function() - return vim.fn.exepath("python3") or "python" - end, - }, - { - type = "python", - request = "launch", - name = "Debug all tests", - module = "unittest", - args = { "discover", "-s", "test", "-v" }, - cwd = "${workspaceFolder}", - pythonPath = function() - return vim.fn.exepath("python3") or "python" - end, - }, - } - - vim.keymap.set("n", "", dap.toggle_breakpoint, { desc = "Toggle breakpoint" }) - vim.keymap.set("n", "", dap.continue, { desc = "Continue" }) - vim.keymap.set("n", "", dap.step_over, { desc = "Step over" }) - vim.keymap.set("n", "", dap.step_into, { desc = "Step into" }) - vim.keymap.set("n", "", dap.step_out, { desc = "Step out" }) - vim.keymap.set("n", "", dap.repl.open, { desc = "Open REPL" }) - vim.keymap.set("n", "", dap.run_last, { desc = "Run last debug config" }) - vim.keymap.set("n", "", dapui.toggle, { desc = "Toggle DAP UI" }) - end, - }, -}