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)