From 62f4f484d7f077733465ed46fa6d6ca70b38c7d0 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 16 May 2024 21:20:24 +0200 Subject: [PATCH] feat(lsp): enable inlay hints by default on Neovim 0.10 --- lua/lazyvim/plugins/lsp/init.lua | 44 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 26abffa0..41a89724 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -38,7 +38,7 @@ return { -- Be aware that you also will need to properly configure your LSP server to -- provide the inlay hints. inlay_hints = { - enabled = false, + enabled = true, }, -- Enable this to enable the builtin LSP code lenses on Neovim >= 0.10.0 -- Be aware that you also will need to properly configure your LSP server to @@ -140,27 +140,29 @@ return { end end - -- inlay hints - if opts.inlay_hints.enabled then - LazyVim.lsp.on_attach(function(client, buffer) - if client.supports_method("textDocument/inlayHint") then - LazyVim.toggle.inlay_hints(buffer, true) - end - end) - end + if vim.fn.has("nvim-0.10") == 1 then + -- inlay hints + if opts.inlay_hints.enabled then + LazyVim.lsp.on_attach(function(client, buffer) + if client.supports_method("textDocument/inlayHint") then + LazyVim.toggle.inlay_hints(buffer, true) + end + end) + end - -- code lens - if opts.codelens.enabled and vim.lsp.codelens then - LazyVim.lsp.on_attach(function(client, buffer) - if client.supports_method("textDocument/codeLens") then - vim.lsp.codelens.refresh() - --- autocmd BufEnter,CursorHold,InsertLeave lua vim.lsp.codelens.refresh() - vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, { - buffer = buffer, - callback = vim.lsp.codelens.refresh, - }) - end - end) + -- code lens + if opts.codelens.enabled and vim.lsp.codelens then + LazyVim.lsp.on_attach(function(client, buffer) + if client.supports_method("textDocument/codeLens") then + vim.lsp.codelens.refresh() + --- autocmd BufEnter,CursorHold,InsertLeave lua vim.lsp.codelens.refresh() + vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, { + buffer = buffer, + callback = vim.lsp.codelens.refresh, + }) + end + end) + end end if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then