From e6f26f0f23e9cb4c6bcc351b06474f4863319aff Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 20 Mar 2026 12:13:32 +0100 Subject: [PATCH] feat(typescript): set `vim.g.lazyvim_ts_lsp = "tsgo"` to use the much faster experimental lsp server --- .../plugins/extras/lang/typescript.lua | 71 +++++++++++++++++-- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index bc91e830..9bb459c6 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -1,3 +1,12 @@ +if lazyvim_docs then + -- LSP Server to use for TypeScript. + vim.g.lazyvim_ts_lsp = "vtsls" -- currently the default + -- Set to "tsgo" to use the new typescript-language-server implementation instead of tsserver. + vim.g.lazyvim_ts_lsp = "tsgo" +end + +local lsp = vim.g.lazyvim_ts_lsp or "vtsls" + return { recommended = function() return LazyVim.extras.wants({ @@ -19,13 +28,50 @@ return { opts = { -- make sure mason installs the server servers = { - --- @deprecated -- tsserver renamed to ts_ls but not yet released, so keep this for now - --- the proper approach is to check the nvim-lspconfig release version when it's released to determine the server name dynamically - tsserver = { - enabled = false, - }, - ts_ls = { - enabled = false, + ---@type lspconfig.settings.tsgo + tsgo = { + -- explicitly add default filetypes, so that we can extend + -- them in related extras + filetypes = { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + }, + settings = { + typescript = { + inlayHints = { + parameterNames = { + enabled = "literals", + suppressWhenArgumentMatchesName = true, + }, + parameterTypes = { enabled = true }, + variableTypes = { enabled = true }, + propertyDeclarationTypes = { enabled = true }, + functionLikeReturnTypes = { enabled = true }, + enumMemberValues = { enabled = true }, + }, + }, + }, + keys = { + { + "co", + LazyVim.lsp.action["source.organizeImports"], + desc = "Organize Imports", + }, + { + "cu", + LazyVim.lsp.action["source.removeUnused.ts"], + desc = "Remove unused imports", + }, + { + "cD", + LazyVim.lsp.action["source.fixAll.ts"], + desc = "Fix all diagnostics", + }, + }, }, vtsls = { -- explicitly add default filetypes, so that we can extend @@ -194,6 +240,17 @@ return { }, }, + { + "neovim/nvim-lspconfig", + opts = function(_, opts) + local servers = { "tsserver", "ts_ls", "vtsls", "tsgo", lsp } + for _, server in ipairs(servers) do + opts.servers[server] = opts.servers[server] or {} + opts.servers[server].enabled = server == lsp + end + end, + }, + { "mfussenegger/nvim-dap", optional = true,