From 19101125be0c393a6088119c8b1e59aed51f850a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sun, 7 Jan 2024 13:13:58 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(nvim):=20moved=20?= =?UTF-8?q?typescript=20inlayhints=20to=20the=20typescript=20extra=20and?= =?UTF-8?q?=20changed=20some=20maps=20for=20the=20lsp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/nvim/lazy-lock.json | 2 +- .../extras/lang/web/typescript-extended.lua | 33 +++++++ .config/nvim/lua/plugins/lspconfig.lua | 91 +------------------ 3 files changed, 39 insertions(+), 87 deletions(-) diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index b9fcd1a1..1278d7b6 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -2,7 +2,7 @@ "LazyVim": { "branch": "main", "commit": "879e29504d43e9f178d967ecc34d482f902e5a91" }, "LuaSnip": { "branch": "master", "commit": "2f0db89fcb22d27b908b3609d2441c02798106ab" }, "SchemaStore.nvim": { "branch": "main", "commit": "7ccffe69a8c24fcd8637788955e13d7fd8aa2f46" }, - "actions-preview.nvim": { "branch": "master", "commit": "8f79029a36ab6807478f157538a91ccd4af5858f" }, + "actions-preview.nvim": { "branch": "master", "commit": "dd63df1a4ed0ffe1458945ee50ecb1dd02b605ab" }, "animation.nvim": { "branch": "main", "commit": "fb77091ab72ec9971aee0562e7081182527aaa6a" }, "autolist.nvim": { "branch": "main", "commit": "5f70a5f99e96c8fe3069de042abd2a8ed2deb855" }, "bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" }, 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 f09d801a..5494bf37 100644 --- a/.config/nvim/lua/plugins/extras/lang/web/typescript-extended.lua +++ b/.config/nvim/lua/plugins/extras/lang/web/typescript-extended.lua @@ -1,6 +1,39 @@ +local inlayHints = { + includeInlayParameterNameHints = "all", + includeInlayParameterNameHintsWhenArgumentMatchesName = true, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = true, + includeInlayVariableTypeHintsWhenTypeMatchesName = true, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, +} + return { { import = "lazyvim.plugins.extras.lang.typescript" }, { import = "lazyvim.plugins.extras.lang.json" }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + tsserver = { + init_options = { + preferences = { + disableSuggestions = true, + }, + }, + settings = { + typescript = { + inlayHints = inlayHints, + }, + javascript = { + inlayHints = inlayHints, + }, + }, + }, + }, + }, + }, { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index 49d62338..81841342 100644 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -1,23 +1,5 @@ local nvim_0_10 = vim.fn.has("nvim-0.10") -local function toggle_diag_virtext() - local virtual_text = { -- Default virtual_text opts from Lazy.Nvim - spacing = 4, - source = "if_many", - prefix = "●", - } - local config = vim.diagnostic.config() - if type(config.virtual_text) == "table" then - config.virtual_text = false - vim.diagnostic.config(config) - vim.notify("Disable diagnostics virtualtext", 5, { title = "Diagnostics" }) - else - config.virtual_text = virtual_text - vim.diagnostic.config(config) - vim.notify("Enabled diagnostics virtualtext", 5, { title = "Diagnostics" }) - end -end - return { { "neovim/nvim-lspconfig", @@ -26,7 +8,9 @@ return { keys[#keys + 1] = { "cl", false } keys[#keys + 1] = { "cil", "LspInfo", desc = "Lsp" } - keys[#keys + 1] = { "uv", toggle_diag_virtext, desc = "Toggle Diagnostic VirtualText" } + keys[#keys + 1] = { "clr", "LspRestart", desc = "Restart Lsp" } + keys[#keys + 1] = { "cls", "LspStart", desc = "Start Lsp" } + keys[#keys + 1] = { "clS", "LspStop", desc = "Stop Lsp" } -- stylua: ignore keys[#keys + 1] = { "cll", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))", desc = "List Workspace" } @@ -37,9 +21,6 @@ return { keys[#keys + 1] = { "clh", vim.lsp.codelens.run, desc = "Run Code Lens" } keys[#keys + 1] = { "cld", vim.lsp.codelens.refresh, desc = "Refresh Code Lens" } - keys[#keys + 1] = { "clr", "LspRestart", desc = "Restart Lsp" } - keys[#keys + 1] = { "cls", "LspStart", desc = "Start Lsp" } - keys[#keys + 1] = { "clS", "LspStop", desc = "Stop Lsp" } end, opts = { -- options for vim.diagnostic.config() @@ -71,81 +52,19 @@ return { enabled = nvim_0_10, }, servers = { - -- typos_lsp = { - -- settings = { - -- diagnosticSeverity = "Warning", TODO: Look at this - -- }, - -- }, lua_ls = { settings = { Lua = { hint = { - enable = true, - setType = true, + enable = nvim_0_10, + setType = nvim_0_10, }, }, }, }, - tsserver = { - init_options = { - preferences = { - disableSuggestions = true, - }, - }, - settings = { - typescript = { - format = { - indentSize = vim.o.shiftwidth, - convertTabsToSpaces = vim.o.expandtab, - tabSize = vim.o.tabstop, - }, - inlayHints = { - includeInlayParameterNameHints = "all", - includeInlayParameterNameHintsWhenArgumentMatchesName = true, - includeInlayFunctionParameterTypeHints = true, - includeInlayVariableTypeHints = true, - includeInlayVariableTypeHintsWhenTypeMatchesName = true, - includeInlayPropertyDeclarationTypeHints = true, - includeInlayFunctionLikeReturnTypeHints = true, - includeInlayEnumMemberValueHints = true, - }, - }, - javascript = { - format = { - indentSize = vim.o.shiftwidth, - convertTabsToSpaces = vim.o.expandtab, - tabSize = vim.o.tabstop, - }, - inlayHints = { - includeInlayParameterNameHints = "all", - includeInlayParameterNameHintsWhenArgumentMatchesName = true, - includeInlayFunctionParameterTypeHints = true, - includeInlayVariableTypeHints = true, - includeInlayVariableTypeHintsWhenTypeMatchesName = true, - includeInlayPropertyDeclarationTypeHints = true, - includeInlayFunctionLikeReturnTypeHints = true, - includeInlayEnumMemberValueHints = true, - }, - }, - completions = { - completeFunctionCalls = true, - }, - }, - }, }, }, }, - { - "simrat39/rust-tools.nvim", - optional = true, - opts = function(_, opts) - opts.tools = { - inlay_hints = { - auto = not nvim_0_10, - }, - } - end, - }, { "folke/which-key.nvim", opts = {