From fbe14666dada719fa5e771e015de01a104789658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sun, 7 Jan 2024 13:14:31 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(nvim):=20add=20deno=20and=20dy?= =?UTF-8?q?namic=20activation=20to=20the=20typescript=20extra?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extras/lang/web/typescript-extended.lua | 84 ++++++------------- .config/pacman/arch-packages.txt | 1 + 2 files changed, 27 insertions(+), 58 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 5494bf37..d2e28a9f 100644 --- a/.config/nvim/lua/plugins/extras/lang/web/typescript-extended.lua +++ b/.config/nvim/lua/plugins/extras/lang/web/typescript-extended.lua @@ -9,9 +9,26 @@ local inlayHints = { includeInlayEnumMemberValueHints = true, } +local function denoConfigExists() + local root = require("lazyvim.util.root").get() .. "/deno.json" + + if vim.fn.filereadable(root) == 1 then + return true + end + + return false +end + return { { import = "lazyvim.plugins.extras.lang.typescript" }, { import = "lazyvim.plugins.extras.lang.json" }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "deno" }) + end, + }, { "neovim/nvim-lspconfig", opts = { @@ -31,6 +48,15 @@ return { }, }, }, + denols = { + root_dir = require("lspconfig").util.root_pattern("deno.json", "deno.jsonc", "deno.lock"), + }, + }, + setup = { + tsserver = function(_, opts) + -- Disable tsserver if denols is present + return denoConfigExists() + end, }, }, }, @@ -58,64 +84,6 @@ return { "typescriptreact", }, }, - { - -- TODO: Need to look more into this plugin - "pmizio/typescript-tools.nvim", - enabled = false, - event = { - "BufRead *.js,*.jsx,*.mjs,*.cjs,*ts,*tsx", - "BufNewFile *.js,*.jsx,*.mjs,*.cjs,*ts,*tsx", - }, - dependencies = { - "nvim-lua/plenary.nvim", - "neovim/nvim-lspconfig", - }, - opts = { - on_attach = function(client, bufnr) - client.server_capabilities.documentFormattingProvider = false - client.server_capabilities.documentRangeFormattingProvider = false - - vim.keymap.set( - "n", - "gD", - "TSToolsGoToSourceDefinition", - { buffer = bufnr, desc = "Source Definition" } - ) - - vim.keymap.set( - "n", - "i", - "TSToolsAddMissingImports", - { buffer = bufnr, desc = "Add missing imports" } - ) - vim.keymap.set( - "n", - "o", - "TSToolsOrganizeImports", - { buffer = bufnr, desc = "Organize imports" } - ) - vim.keymap.set( - "n", - "r", - "TSToolsRemoveUnused", - { buffer = bufnr, desc = "Remove unused variables" } - ) - vim.keymap.set("n", "f", "TSToolsFixAll", { buffer = bufnr, desc = "Fix all" }) - end, - settings = { - tsserver_file_preferences = { - includeInlayParameterNameHints = "all", - includeInlayParameterNameHintsWhenArgumentMatchesName = false, - includeInlayFunctionParameterTypeHints = true, - includeInlayVariableTypeHints = true, - includeInlayPropertyDeclarationTypeHints = true, - includeInlayFunctionLikeReturnTypeHints = true, - includeInlayEnumMemberValueHints = true, - }, - }, - code_lens = "all", - }, - }, { "nvim-neotest/neotest", optional = true, diff --git a/.config/pacman/arch-packages.txt b/.config/pacman/arch-packages.txt index 4a9decf0..35865dc6 100644 --- a/.config/pacman/arch-packages.txt +++ b/.config/pacman/arch-packages.txt @@ -23,6 +23,7 @@ clamtk 6.14-1 cliphist 1:0.4.0-2 cpupower 6.6-1 dbeaver 23.3.1-1 +deno 1.39.1-1 dialog 1:1.3_20231002-1 dictd 1.13.1-5 diff-so-fancy 1.4.4-2