♻️ refactor(nvim): typescript-extended extra now uses vstls instead of typescript-tools and tsserver
This commit is contained in:
parent
1f44b1bc01
commit
a0c4638365
1 changed files with 1 additions and 110 deletions
|
@ -1,29 +1,3 @@
|
||||||
local ts_server_activated = true -- Change this variable to false if you want to use typescript-tools instead of lspconfig tsserver implementation
|
|
||||||
local ft = { "typescript", "typescriptreact", "javascript", "javascriptreact" }
|
|
||||||
|
|
||||||
local inlayHints = {
|
|
||||||
includeInlayParameterNameHints = "all",
|
|
||||||
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
|
|
||||||
includeInlayFunctionParameterTypeHints = true,
|
|
||||||
includeInlayVariableTypeHints = true,
|
|
||||||
includeInlayVariableTypeHintsWhenTypeMatchesName = true,
|
|
||||||
includeInlayPropertyDeclarationTypeHints = true,
|
|
||||||
includeInlayFunctionLikeReturnTypeHints = true,
|
|
||||||
includeInlayEnumMemberValueHints = true,
|
|
||||||
}
|
|
||||||
|
|
||||||
local source_action = function(name)
|
|
||||||
return function()
|
|
||||||
vim.lsp.buf.code_action({
|
|
||||||
apply = true,
|
|
||||||
context = {
|
|
||||||
only = { string.format("source.%s.ts", name) },
|
|
||||||
diagnostics = {},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
||||||
{ import = "plugins.extras.lang.json-extended" },
|
{ import = "plugins.extras.lang.json-extended" },
|
||||||
|
@ -38,106 +12,23 @@ return {
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
opts = {
|
opts = {
|
||||||
servers = {
|
servers = {
|
||||||
tsserver = {
|
vtsls = {
|
||||||
handlers = {
|
handlers = {
|
||||||
["textDocument/publishDiagnostics"] = function(err, result, ctx, config)
|
["textDocument/publishDiagnostics"] = function(err, result, ctx, config)
|
||||||
require("ts-error-translator").translate_diagnostics(err, result, ctx, config)
|
require("ts-error-translator").translate_diagnostics(err, result, ctx, config)
|
||||||
vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx, config)
|
vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx, config)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
enabled = ts_server_activated,
|
|
||||||
init_options = {
|
init_options = {
|
||||||
preferences = {
|
preferences = {
|
||||||
disableSuggestions = true,
|
disableSuggestions = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
settings = {
|
|
||||||
typescript = {
|
|
||||||
inlayHints = inlayHints,
|
|
||||||
implementationsCodeLens = {
|
|
||||||
enabled = true,
|
|
||||||
},
|
|
||||||
referencesCodeLens = {
|
|
||||||
enabled = true,
|
|
||||||
showOnAllFunctions = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
javascript = {
|
|
||||||
inlayHints = inlayHints,
|
|
||||||
implementationsCodeLens = {
|
|
||||||
enabled = true,
|
|
||||||
},
|
|
||||||
referencesCodeLens = {
|
|
||||||
enabled = true,
|
|
||||||
showOnAllFunctions = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
keys = {
|
|
||||||
{
|
|
||||||
"<leader>cO",
|
|
||||||
source_action("organizeImports"),
|
|
||||||
desc = "Organize Imports",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"<leader>cM",
|
|
||||||
source_action("addMissingImports"),
|
|
||||||
desc = "Add Missing Imports",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"<leader>cR",
|
|
||||||
source_action("removeUnused"),
|
|
||||||
desc = "Remove Unused Imports",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
denols = {},
|
denols = {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"pmizio/typescript-tools.nvim",
|
|
||||||
dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
|
|
||||||
enabled = not ts_server_activated,
|
|
||||||
ft = ft,
|
|
||||||
opts = {
|
|
||||||
cmd = { "typescript-language-server", "--stdio" },
|
|
||||||
handlers = {
|
|
||||||
["textDocument/publishDiagnostics"] = function(err, result, ctx, config)
|
|
||||||
require("ts-error-translator").translate_diagnostics(err, result, ctx, config)
|
|
||||||
vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx, config)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
settings = {
|
|
||||||
code_lens = "all",
|
|
||||||
expose_as_code_action = "all",
|
|
||||||
tsserver_plugins = {
|
|
||||||
"@styled/typescript-styled-plugin",
|
|
||||||
},
|
|
||||||
tsserver_file_preferences = {
|
|
||||||
completions = {
|
|
||||||
completeFunctionCalls = true,
|
|
||||||
},
|
|
||||||
init_options = {
|
|
||||||
preferences = {
|
|
||||||
disableSuggestions = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
includeInlayParameterNameHints = "all",
|
|
||||||
includeInlayEnumMemberValueHints = true,
|
|
||||||
includeInlayFunctionLikeReturnTypeHints = true,
|
|
||||||
includeInlayFunctionParameterTypeHints = true,
|
|
||||||
includeInlayPropertyDeclarationTypeHints = true,
|
|
||||||
includeInlayVariableTypeHints = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
keys = {
|
|
||||||
{ "<leader>cO", ft = ft, "<cmd>TSToolsOrganizeImports<cr>", desc = "Organize Imports" },
|
|
||||||
{ "<leader>cR", ft = ft, "<cmd>TSToolsRemoveUnusedImports<cr>", desc = "Remove Unused Imports" },
|
|
||||||
{ "<leader>cM", ft = ft, "<cmd>TSToolsAddMissingImports<cr>", desc = "Add Missing Imports" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
|
|
Loading…
Add table
Reference in a new issue