Skip to content
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

nvim-lsp: inlay hints not working? #4

Closed
lnicola opened this issue Feb 1, 2021 · 17 comments
Closed

nvim-lsp: inlay hints not working? #4

lnicola opened this issue Feb 1, 2021 · 17 comments

Comments

@lnicola
Copy link
Contributor

lnicola commented Feb 1, 2021

image

I'm using your snippet:

autocmd CursorMoved,InsertLeave,BufEnter,BufWinEnter,TabEnter,BufWritePost *
\ lua require'lsp_extensions'.inlay_hints{ prefix = '', highlight = "Comment" }

Tested with nvim 0.5.0+dev+1062+gcc1851c9f-1.

@lnicola lnicola changed the title Inlay hints not working? nvim-lsp: inlay hints not working? Feb 1, 2021
@lnicola
Copy link
Contributor Author

lnicola commented Feb 1, 2021

Found nvim-lua/lsp_extensions.nvim#20, but the suggestion there doesn't seem to do anything for me.

@lnicola
Copy link
Contributor Author

lnicola commented Feb 1, 2021

Actually they do show up, but only after editing the code? https://asciinema.org/a/wBwj7uKmjeSmN4fL8KgBuYddI

Right now I have:

+ autocmd BufEnter,BufWinEnter,TabEnter *.rs :lua require'lsp_extensions'.inlay_hints{ prefix = '', highlight = "Comment", enabled = {"TypeHint", "ChainingHint", "ParameterHint"}}

@sharksforarms
Copy link
Owner

It will only start showing once the LSP kicks in (rust-analyzer) which for me seems to be after first write (:w)

@lnicola
Copy link
Contributor Author

lnicola commented Feb 1, 2021

Hmm, for me LSP features are working even before a :w, and I see the server starting up right from the beginning.

@sharksforarms
Copy link
Owner

I can take a look at this later tonight, could you provide your config?

@lnicola
Copy link
Contributor Author

lnicola commented Feb 1, 2021

Sorry, it's a bit messy: https://gist.github.com/lnicola/1276f4c205361960ffd23b1a4c2cea62

Anyway, don't worry, this doesn't seem terribly important.

@sharksforarms
Copy link
Owner

I believe it's your autocmds combination. For example, triggering any of those autocmds makes them show properly.

I think what's happening is that the LSP isn't started yet when the file opens, so the request for hints fails. Could be possible to call inlay hints when the LSP is started?

You could also try adding a more frequent autocmd like CursorHold

Here is my list: autocmd BufEnter,BufWinEnter,BufWritePost,InsertLeave,TabEnter

@sharksforarms
Copy link
Owner

Let me know if you need anything else!

@ruffson
Copy link
Contributor

ruffson commented Mar 12, 2021

I have the same problem, inlay hints stopped working for whatever reason. When I Iook at the lsp.log in ~/.cache/nvim right after opening a workspace with a few buffers it says:

[ WARN ] 2021-03-12T14:17:26+0100 ] ...ount_nvim.aNPuIQD/usr/share/nvim/runtime/lua/vim/lsp.lua:84 ]    "method rust-analyzer/inlayHints is not supported by any of the servers registered for the current buffer"

I am using the appimage neovim bin. If I use your exact config file, I do have inlay hints but when I use mine which contains your settings almost excately it doesn't anymore. Which is driving me mad. I have no idea what is happening here. The only thing that is different from yours is that my plugs are in the default neovim folder and not in ~/.vim/.

The rust_analyzer is available in my path. Do you have any idea what this could be or how I could debug it?
When I do :LspInfo everything looks correct.

@Antonio-Bennett
Copy link

I have the same problem, inlay hints stopped working for whatever reason. When I Iook at the lsp.log in ~/.cache/nvim right after opening a workspace with a few buffers it says:

[ WARN ] 2021-03-12T14:17:26+0100 ] ...ount_nvim.aNPuIQD/usr/share/nvim/runtime/lua/vim/lsp.lua:84 ]    "method rust-analyzer/inlayHints is not supported by any of the servers registered for the current buffer"

I am using the appimage neovim bin. If I use your exact config file, I do have inlay hints but when I use mine which contains your settings almost excately it doesn't anymore. Which is driving me mad. I have no idea what is happening here. The only thing that is different from yours is that my plugs are in the default neovim folder and not in ~/.vim/.

The rust_analyzer is available in my path. Do you have any idea what this could be or how I could debug it?
When I do :LspInfo everything looks correct.

Did you figure it out? Getting the same issue as well I have the rust analyzer binary installed configured correctly with native lsp and same here :LspInfo shows rust-analyzer is registered

@ruffson
Copy link
Contributor

ruffson commented Mar 29, 2021

@Antonio-Bennett Man I have no idea. It worked for me again. But I don't remember why and what changed. No single action I took, brought it back but rather changing everything, re-installing everything out of desperation, etc.
This is my current init.vim but as with your experience there is no clear reason why it should not have worked previously.

@Antonio-Bennett
Copy link

Lool same! Just started working all of a sudden!

@marcelarie
Copy link

Any news about how to make this work? :)

@Antonio-Bennett
Copy link

Hey @marcelarie I use the lsp_extensions plugin found here https://github.com/nvim-lua/lsp_extensions.nvim then I add this to my init.lua or init.vim whichever one you have

vim.cmd [[ autocmd CursorMoved,InsertLeave,BufEnter,BufWinEnter,TabEnter,BufWritePost * :lua require'lsp_extensions'.inlay_hints{ prefix = '=>', highlight = "Comment", enabled = {"TypeHint", "ChainingHint", "ParameterHint"} } ]]

@sharksforarms
Copy link
Owner

@marcelarie I recommend basing off of: https://github.com/sharksforarms/vim-rust/blob/master/neovim-init-lsp-compe-rust-tools.vim

This uses https://github.com/simrat39/rust-tools.nvim which supports inlay hints and more

@marcelarie
Copy link

Ok I tried rust-tools and its really good, I am going to stick with that👌 thanks to both!!

@Antonio-Bennett
Copy link

Ouuu Rust tools looks real nice think im gonna switch over as well 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants