aboutsummaryrefslogtreecommitdiffstats
path: root/lua/pi/lsp/attach.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/pi/lsp/attach.lua')
-rw-r--r--lua/pi/lsp/attach.lua13
1 files changed, 12 insertions, 1 deletions
diff --git a/lua/pi/lsp/attach.lua b/lua/pi/lsp/attach.lua
index 03002d6..24842fe 100644
--- a/lua/pi/lsp/attach.lua
+++ b/lua/pi/lsp/attach.lua
@@ -16,6 +16,13 @@ return function(client, bufnr)
}
end, { buffer = 0, desc = "LSP format file" })
+ -- Add inlay hint toggle
+ vim.keymap.set("n", "<leader>vh", function()
+ local current = vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr })
+ vim.lsp.inlay_hint.enable(not current, { bufnr = bufnr })
+ vim.notify("Inlay hints " .. (current and "disabled" or "enabled"))
+ end, { buffer = 0, desc = "LSP Toggle inlay hints" })
+
telescope_mapper("gr", "lsp_references", { buffer = true, desc = "LSP References of symbol on cursor" })
telescope_mapper("<leader>pv", "find_symbol", { buffer = true, desc = "LSP find symbol on the project" })
telescope_mapper("<leader>pd", "lsp_document_symbols", { buffer = true, desc = "LSP document symbols" })
@@ -23,7 +30,11 @@ return function(client, bufnr)
vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
+ -- Enable inlay hints if supported (Neovim 0.11+ compatible)
+ -- Use pcall to handle any potential errors with inlay hints
if client.server_capabilities.inlayHintProvider then
- vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
+ pcall(function()
+ vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
+ end)
end
end