diff --git a/term/.config/nvim/lua/plugins/debugging.lua b/term/.config/nvim/lua/plugins/debugging.lua index d9ef3fd..3e1dbbe 100644 --- a/term/.config/nvim/lua/plugins/debugging.lua +++ b/term/.config/nvim/lua/plugins/debugging.lua @@ -1,7 +1,9 @@ --[[ DEBUGGING.LUA - nvim-dap for Python debugging - Requirements: pip install debugpy + nvim-dap for Python and JavaScript/TypeScript debugging + Requirements: + Python: pip install debugpy + JS/TS: Build vscode-js-debug manually (see below) ]] return { @@ -24,3 +26,42 @@ return { }, { "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, + }, +--]] diff --git a/term/.config/nvim/lua/plugins/lsp-config.lua b/term/.config/nvim/lua/plugins/lsp-config.lua index db47035..2d10442 100644 --- a/term/.config/nvim/lua/plugins/lsp-config.lua +++ b/term/.config/nvim/lua/plugins/lsp-config.lua @@ -14,6 +14,7 @@ return { require("mason-lspconfig").setup({ ensure_installed = { "pyright", -- Python + "tsserver", -- TypeScript/JavaScript "jsonls", -- JSON "yamlls", -- YAML "html", -- HTML @@ -41,7 +42,7 @@ return { }, }) - -- Other languages + -- Python vim.lsp.config("pyright", { settings = { 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("yamlls", {}) vim.lsp.config("html", {}) @@ -61,6 +92,7 @@ return { -- Enable servers vim.lsp.enable("lua_ls") vim.lsp.enable("pyright") + vim.lsp.enable("tsserver") vim.lsp.enable("jsonls") vim.lsp.enable("yamlls") vim.lsp.enable("html") diff --git a/term/.config/nvim/lua/plugins/none-ls.lua b/term/.config/nvim/lua/plugins/none-ls.lua index 1c610bf..5bc5b0a 100644 --- a/term/.config/nvim/lua/plugins/none-ls.lua +++ b/term/.config/nvim/lua/plugins/none-ls.lua @@ -10,6 +10,8 @@ return { null_ls.builtins.formatting.black, null_ls.builtins.diagnostics.black, null_ls.builtins.formatting.prettier, + null_ls.builtins.diagnostics.eslint, + null_ls.builtins.formatting.eslint, null_ls.builtins.formatting.shfmt, null_ls.builtins.diagnostics.shellcheck, }, diff --git a/term/.config/nvim/lua/plugins/treesitter.lua b/term/.config/nvim/lua/plugins/treesitter.lua index 6fce23b..775e48c 100644 --- a/term/.config/nvim/lua/plugins/treesitter.lua +++ b/term/.config/nvim/lua/plugins/treesitter.lua @@ -8,7 +8,7 @@ return { if ok then configs.setup({ auto_install = true, - -- ensure_installed = { "python", "lua", "json", "yaml", "markdown" }, + ensure_installed = { "python", "lua", "json", "yaml", "javascript", "typescript" }, highlight = { enable = true }, indent = { enable = true }, })