refactor(typescript): split typescript dap from lang

This commit is contained in:
Andre Freitas 2023-10-18 19:09:58 +01:00
parent ae77bfda89
commit 3d06d229d4
2 changed files with 58 additions and 54 deletions

View file

@ -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,
},
}

View file

@ -1,5 +1,4 @@
return { return {
-- add typescript to treesitter -- add typescript to treesitter
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
@ -9,7 +8,6 @@ return {
end end
end, end,
}, },
-- correctly setup lspconfig -- correctly setup lspconfig
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
@ -34,14 +32,18 @@ return {
}, },
}, },
settings = { settings = {
---@diagnostic disable-next-line: missing-fields
typescript = { typescript = {
---@diagnostic disable-next-line: missing-fields
format = { format = {
indentSize = vim.o.shiftwidth, indentSize = vim.o.shiftwidth,
convertTabsToSpaces = vim.o.expandtab, convertTabsToSpaces = vim.o.expandtab,
tabSize = vim.o.tabstop, tabSize = vim.o.tabstop,
}, },
}, },
---@diagnostic disable-next-line: missing-fields
javascript = { javascript = {
---@diagnostic disable-next-line: missing-fields
format = { format = {
indentSize = vim.o.shiftwidth, indentSize = vim.o.shiftwidth,
convertTabsToSpaces = vim.o.expandtab, 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,
},
} }