diff --git a/lua/lazyvim/plugins/extras/dap/typescript.lua b/lua/lazyvim/plugins/extras/dap/typescript.lua new file mode 100644 index 00000000..28e8b42a --- /dev/null +++ b/lua/lazyvim/plugins/extras/dap/typescript.lua @@ -0,0 +1,54 @@ +return { + { + "mfussenegger/nvim-dap", + optional = true, + 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, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 4af1deec..4c7cf05f 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -1,5 +1,4 @@ return { - -- add typescript to treesitter { "nvim-treesitter/nvim-treesitter", @@ -9,7 +8,6 @@ return { end end, }, - -- correctly setup lspconfig { "neovim/nvim-lspconfig", @@ -34,14 +32,18 @@ return { }, }, settings = { + ---@diagnostic disable-next-line: missing-fields typescript = { + ---@diagnostic disable-next-line: missing-fields format = { indentSize = vim.o.shiftwidth, convertTabsToSpaces = vim.o.expandtab, tabSize = vim.o.tabstop, }, }, + ---@diagnostic disable-next-line: missing-fields javascript = { + ---@diagnostic disable-next-line: missing-fields format = { indentSize = vim.o.shiftwidth, convertTabsToSpaces = vim.o.expandtab, @@ -56,56 +58,4 @@ return { }, }, }, - { - "mfussenegger/nvim-dap", - optional = true, - 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, - }, }