-
Notifications
You must be signed in to change notification settings - Fork 25.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
turn inlay hints on by default? #948
Comments
How about adding it like this, instead? if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
-- Toggle inlay hints
map('<leader>th', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
end, '[T]oggle Inlay [H]ints')
-- Enable inlay hints by default
vim.lsp.inlay_hint.enable()
end This way, inlay hints will be on by default and you can toggle them with |
Oh, wow. That's great, thanks. Exactly what I was trying to do and in a much better way. |
Well, I thought this should work, but inlay hints are not enabling until I toggle it twice, still. Am I using the enable() function wrong? |
Ok, so it does seem to be activating inlay hints. However, they aren't showing up until something in the code changes. If I force rust_analyzer to reevaluate the code by changing whitespace above or below where I should see an inlay, for instance, it shows up. Otherwise I need to toggle it twice. Is there an additional code I need to make it display them automatically without needing to change something or manually toggle it twice? |
I'm using rustaceanvim and it works normally. I guess the issue you're describing is related to this, which rustaceanvim is working around here. |
Would be great to have a commented section with -- Remove comment to enable inlay hints by default |
It appears some of this code made it into the last release. if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
-- Toggle inlay hints
map('<leader>th', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
end, '[T]oggle Inlay [H]ints')
-- Enable inlay hints by default
vim.lsp.inlay_hint.enable()
end When I go through diagnostic errors in a (basically) new kickstart.nvim file, I am getting an error stating "This function requires 1 argument but instead it is receiving 0 for the is_enabled() call. The diagnostic error goes away when I add a table Edit: It looks like you can just drop the parens after is_enabled. They seem to be throwing the diagnostic error. |
Curious why that doesn't work for you considering that's how it's written in the Neovim docs. It still works for me, but deleting the parens works as well. Is it a difference in versions? I'm using Neovim v0.10.0 |
I, too, am using v0.10.0. I can't say for certain that it "doesn't work" but I was getting diagnostic errors for the issue. |
Oh, that's just a warning not an error, so you can safely ignore it. I didn't see it before because I had turned off some neodev diagnostics. It's worth noting that I thought removing the parens worked at first, but with that the toggle only works once, then it stops working. Replacing the parens with curly braces worked, though, and the warning disappeared as well: vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled {}) Don't know what the ramifications of this is are, though. |
|
Fixed in a recent merge. |
Not quite fixed (because the initial issue wasn't a bug, more of a question), but I think it's overall resolved apart from the neovim issue. |
I just updated to the most recent commit for kickstart.nvim and I'm happy to see a toggle now for inlay hints.
However, I want it on by default and able to be toggled off. I understand the
<leader>th
keymap will toggle to the inverse of the current state, so I tried adding this to my init.lua near myvim.opt
s.The toggle will still work if I toggle it twice (I'm assuming the first one is setting it to 'off' after my code messes up the state), but I can't get it to default on. How do I fix this?
The text was updated successfully, but these errors were encountered: