From f60979981c969b5e111e94b0c39756a02c919d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Thu, 19 Oct 2023 13:26:02 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(nvim):=20js/ts=20debugging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/nvim/lua/plugins/mason.lua | 1 + .config/nvim/lua/plugins/treesj.lua | 9 ++++ .config/nvim/lua/plugins/vs-code-debug.lua | 53 ++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 .config/nvim/lua/plugins/treesj.lua create mode 100644 .config/nvim/lua/plugins/vs-code-debug.lua diff --git a/.config/nvim/lua/plugins/mason.lua b/.config/nvim/lua/plugins/mason.lua index 1f576835..88aca6cf 100644 --- a/.config/nvim/lua/plugins/mason.lua +++ b/.config/nvim/lua/plugins/mason.lua @@ -32,6 +32,7 @@ return { "gomodifytags", "isort", "stylelint", + "js-debug-adapter", }, }, }, diff --git a/.config/nvim/lua/plugins/treesj.lua b/.config/nvim/lua/plugins/treesj.lua new file mode 100644 index 00000000..5ddb74b0 --- /dev/null +++ b/.config/nvim/lua/plugins/treesj.lua @@ -0,0 +1,9 @@ +return { + { + "Wansmer/treesj", + keys = { + { "J", "TSJToggle", desc = "Join Toggle" }, + }, + opts = { use_default_keymaps = false, max_join_length = 150 }, + }, +} diff --git a/.config/nvim/lua/plugins/vs-code-debug.lua b/.config/nvim/lua/plugins/vs-code-debug.lua new file mode 100644 index 00000000..4706bec9 --- /dev/null +++ b/.config/nvim/lua/plugins/vs-code-debug.lua @@ -0,0 +1,53 @@ +return { + { + "mfussenegger/nvim-dap", + dependencies = { + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + table.insert(opts.ensure_installed, "js-debug-adapter") + end, + }, + }, + opts = function() + local dap = require("dap") + if not dap.adapters["pwa-node"] then + 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 = { + require("mason-registry").get_package("js-debug-adapter"):get_install_path() + .. "/js-debug/src/dapDebugServer.js", + "${port}", + }, + }, + } + end + for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact" }) do + if not dap.configurations[language] then + 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}", + }, + } + end + end + end, + }, +}