From 1c46f544328b084753327a81b92e2b57ab568321 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Sun, 9 Jun 2024 16:48:51 -0400 Subject: [PATCH] fix(typescript): clean up configuration of the vscode dap extension (#3556) `mason-nvim-dap.nvim` adds it's own adapter filetype mappings to the vscode extension in `nvim-dap` (as of https://github.com/jay-babu/mason-nvim-dap.nvim/pull/129) This also moves the type mappings for the `pwa-node` and `node` adapters to where they are defined in the typescript pack. Now that the default internal type mappings are configured we can rely on the automatic loading of the `.vscode/launch.json` that `nvim-dap` does --- lua/lazyvim/plugins/extras/dap/core.lua | 6 ------ lua/lazyvim/plugins/extras/lang/typescript.lua | 8 +++++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lua/lazyvim/plugins/extras/dap/core.lua b/lua/lazyvim/plugins/extras/dap/core.lua index 7bc2345f..b7a088c1 100644 --- a/lua/lazyvim/plugins/extras/dap/core.lua +++ b/lua/lazyvim/plugins/extras/dap/core.lua @@ -87,16 +87,10 @@ return { -- setup dap config by VsCode launch.json file local vscode = require("dap.ext.vscode") - local _filetypes = require("mason-nvim-dap.mappings.filetypes") - local filetypes = vim.tbl_deep_extend("force", _filetypes, { - ["node"] = { "javascriptreact", "typescriptreact", "typescript", "javascript" }, - ["pwa-node"] = { "javascriptreact", "typescriptreact", "typescript", "javascript" }, - }) local json = require("plenary.json") vscode.json_decode = function(str) return vim.json.decode(json.json_strip_comments(str)) end - vscode.load_launchjs(nil, filetypes) end, }, diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 7316ad50..139c3086 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -220,7 +220,13 @@ return { end end - for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact" }) do + local js_filetypes = { "typescript", "javascript", "typescriptreact", "javascriptreact" } + + local vscode = require("dap.ext.vscode") + vscode.type_to_filetypes["node"] = js_filetypes + vscode.type_to_filetypes["pwa-node"] = js_filetypes + + for _, language in ipairs(js_filetypes) do if not dap.configurations[language] then dap.configurations[language] = { {