diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 27736311..feaba085 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -112,6 +112,9 @@ map("n", "ul", function() Util.toggle("relativenumber", true) Util.toggl map("n", "ud", Util.toggle_diagnostics, { desc = "Toggle Diagnostics" }) local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3 map("n", "uc", function() Util.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Toggle Conceal" }) +if vim.lsp.buf.inlay_hint then + map("n", "uh", function() vim.lsp.buf.inlay_hint(0, nil) end, { desc = "Toggle Inlay Hints" }) +end -- lazygit map("n", "gg", function() Util.float_term({ "lazygit" }, { cwd = Util.get_root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 54c69473..260abcae 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -31,6 +31,12 @@ return { }, severity_sort = true, }, + -- Enable this to enable the builtin LSP inlay hints on Neovim >= 0.10.0 + -- Be aware that you also will need to properly configure your LSP server to + -- provide the inlay hints. + inlay_hints = { + enabled = false, + }, -- add any global capabilities here capabilities = {}, -- Automatically format on save @@ -92,6 +98,14 @@ return { vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) end + if opts.inlay_hints.enabled and vim.lsp.buf.inlay_hint then + Util.on_attach(function(client, buffer) + if client.server_capabilities.inlayHintProvider then + vim.lsp.buf.inlay_hint(buffer, true) + end + end) + end + if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●" or function(diagnostic)