mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-21 20:11:06 +00:00
feat(typescript): set vim.g.lazyvim_ts_lsp = "tsgo" to use the much faster experimental lsp server
This commit is contained in:
parent
b2830cfcc5
commit
e6f26f0f23
1 changed files with 64 additions and 7 deletions
|
|
@ -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 = {
|
||||
{
|
||||
"<leader>co",
|
||||
LazyVim.lsp.action["source.organizeImports"],
|
||||
desc = "Organize Imports",
|
||||
},
|
||||
{
|
||||
"<leader>cu",
|
||||
LazyVim.lsp.action["source.removeUnused.ts"],
|
||||
desc = "Remove unused imports",
|
||||
},
|
||||
{
|
||||
"<leader>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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue