From a0c4638365a5556ff78ff73641ad666b57d4e7a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Fri, 31 May 2024 21:22:29 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(nvim):=20typescri?= =?UTF-8?q?pt-extended=20extra=20now=20uses=20vstls=20instead=20of=20types?= =?UTF-8?q?cript-tools=20and=20tsserver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extras/lang/web/typescript-extended.lua | 111 +----------------- 1 file changed, 1 insertion(+), 110 deletions(-) diff --git a/.config/nvim/lua/plugins/extras/lang/web/typescript-extended.lua b/.config/nvim/lua/plugins/extras/lang/web/typescript-extended.lua index 4e7fad8f..43c486ea 100644 --- a/.config/nvim/lua/plugins/extras/lang/web/typescript-extended.lua +++ b/.config/nvim/lua/plugins/extras/lang/web/typescript-extended.lua @@ -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 { { import = "lazyvim.plugins.extras.lang.typescript" }, { import = "plugins.extras.lang.json-extended" }, @@ -38,106 +12,23 @@ return { "neovim/nvim-lspconfig", opts = { servers = { - tsserver = { + vtsls = { 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, }, - enabled = ts_server_activated, init_options = { preferences = { 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 = { - { - "cO", - source_action("organizeImports"), - desc = "Organize Imports", - }, - { - "cM", - source_action("addMissingImports"), - desc = "Add Missing Imports", - }, - { - "cR", - source_action("removeUnused"), - desc = "Remove Unused Imports", - }, - }, }, 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 = { - { "cO", ft = ft, "TSToolsOrganizeImports", desc = "Organize Imports" }, - { "cR", ft = ft, "TSToolsRemoveUnusedImports", desc = "Remove Unused Imports" }, - { "cM", ft = ft, "TSToolsAddMissingImports", desc = "Add Missing Imports" }, - }, - }, { "nvim-treesitter/nvim-treesitter", opts = function(_, opts)