ide features for Typescrript and JavaScript

This commit is contained in:
2026-03-27 09:46:41 +01:00
parent 38ad61c7d1
commit da04ee3883
4 changed files with 79 additions and 4 deletions
+43 -2
View File
@@ -1,7 +1,9 @@
--[[ --[[
DEBUGGING.LUA DEBUGGING.LUA
nvim-dap for Python debugging nvim-dap for Python and JavaScript/TypeScript debugging
Requirements: pip install debugpy Requirements:
Python: pip install debugpy
JS/TS: Build vscode-js-debug manually (see below)
]] ]]
return { return {
@@ -24,3 +26,42 @@ return {
}, },
{ "mfussenegger/nvim-dap-python", dependencies = { "mfussenegger/nvim-dap" } }, { "mfussenegger/nvim-dap-python", dependencies = { "mfussenegger/nvim-dap" } },
} }
--[[
To enable JS/TS debugging:
1. Build vscode-js-debug:
git clone https://github.com/microsoft/vscode-js-debug
cd vscode-js-debug
npm install --legacy-peer-deps
npx gulp vsDebugServerBundle && mv dist out
2. Add this plugin (uncomment inside the return block above):
{
"mxsdev/nvim-dap-vscode-js",
dependencies = { "mfussenegger/nvim-dap" },
config = function()
require("dap-vscode-js").setup({
adapters = { "pwa-node", "pwa-chrome" },
})
for _, language in ipairs({ "typescript", "javascript" }) do
require("dap").configurations[language] = {
{
type = "pwa-node",
request = "launch",
name = "Launch file",
program = "${file}",
cwd = "${workspaceFolder}",
},
{
type = "pwa-node",
request = "attach",
name = "Attach to process",
processId = require("dap.utils").pick_process,
cwd = "${workspaceFolder}",
},
}
end
end,
},
--]]
+33 -1
View File
@@ -14,6 +14,7 @@ return {
require("mason-lspconfig").setup({ require("mason-lspconfig").setup({
ensure_installed = { ensure_installed = {
"pyright", -- Python "pyright", -- Python
"tsserver", -- TypeScript/JavaScript
"jsonls", -- JSON "jsonls", -- JSON
"yamlls", -- YAML "yamlls", -- YAML
"html", -- HTML "html", -- HTML
@@ -41,7 +42,7 @@ return {
}, },
}) })
-- Other languages -- Python
vim.lsp.config("pyright", { vim.lsp.config("pyright", {
settings = { settings = {
python = { python = {
@@ -52,6 +53,36 @@ return {
}, },
}, },
}) })
-- Type- and JavaScript
vim.lsp.config("tsserver", {
settings = {
typescript = {
inlayHints = {
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
javascript = {
inlayHints = {
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
},
})
-- Other languages
vim.lsp.config("jsonls", {}) vim.lsp.config("jsonls", {})
vim.lsp.config("yamlls", {}) vim.lsp.config("yamlls", {})
vim.lsp.config("html", {}) vim.lsp.config("html", {})
@@ -61,6 +92,7 @@ return {
-- Enable servers -- Enable servers
vim.lsp.enable("lua_ls") vim.lsp.enable("lua_ls")
vim.lsp.enable("pyright") vim.lsp.enable("pyright")
vim.lsp.enable("tsserver")
vim.lsp.enable("jsonls") vim.lsp.enable("jsonls")
vim.lsp.enable("yamlls") vim.lsp.enable("yamlls")
vim.lsp.enable("html") vim.lsp.enable("html")
@@ -10,6 +10,8 @@ return {
null_ls.builtins.formatting.black, null_ls.builtins.formatting.black,
null_ls.builtins.diagnostics.black, null_ls.builtins.diagnostics.black,
null_ls.builtins.formatting.prettier, null_ls.builtins.formatting.prettier,
null_ls.builtins.diagnostics.eslint,
null_ls.builtins.formatting.eslint,
null_ls.builtins.formatting.shfmt, null_ls.builtins.formatting.shfmt,
null_ls.builtins.diagnostics.shellcheck, null_ls.builtins.diagnostics.shellcheck,
}, },
+1 -1
View File
@@ -8,7 +8,7 @@ return {
if ok then if ok then
configs.setup({ configs.setup({
auto_install = true, auto_install = true,
-- ensure_installed = { "python", "lua", "json", "yaml", "markdown" }, ensure_installed = { "python", "lua", "json", "yaml", "javascript", "typescript" },
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
}) })