mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-22 20:41:08 +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 {
|
return {
|
||||||
recommended = function()
|
recommended = function()
|
||||||
return LazyVim.extras.wants({
|
return LazyVim.extras.wants({
|
||||||
|
|
@ -19,13 +28,50 @@ return {
|
||||||
opts = {
|
opts = {
|
||||||
-- make sure mason installs the server
|
-- make sure mason installs the server
|
||||||
servers = {
|
servers = {
|
||||||
--- @deprecated -- tsserver renamed to ts_ls but not yet released, so keep this for now
|
---@type lspconfig.settings.tsgo
|
||||||
--- the proper approach is to check the nvim-lspconfig release version when it's released to determine the server name dynamically
|
tsgo = {
|
||||||
tsserver = {
|
-- explicitly add default filetypes, so that we can extend
|
||||||
enabled = false,
|
-- 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",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ts_ls = {
|
|
||||||
enabled = false,
|
|
||||||
},
|
},
|
||||||
vtsls = {
|
vtsls = {
|
||||||
-- explicitly add default filetypes, so that we can extend
|
-- 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",
|
"mfussenegger/nvim-dap",
|
||||||
optional = true,
|
optional = true,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue