LanguageClient-neovim
LanguageClient-neovim copied to clipboard
Inline type inference
Is there a way to get the type inference to be displayed inlined like vscode? Or is this not supported?
Someone said this could be implemented with "conceal text".
The inlay hints are requested by a custom request (rust-analyzer/inlayHints
)
https://github.com/rust-analyzer/rust-analyzer/blob/17dda0972a68dd88a766c223390317dc2cb3ea00/editors/code/src/inlay_hints.ts#L135-L148
I think conceal can only hide text. I think we need to wait until virtual text gets extended in Neovim to be displayed not only in at the end of line but also in the middle. I think this was planned when merging the virtual text commit.
Is it possible to have at least an annotation at the end of the line like CoC has?
Also can someone point to the neovim issues about virtual text?
@akhilman I think that would be fairly simple to implement. It's very specific to rust-analyzer, but we handle extensions already so I suppose we could add this one as well.
@akhilman see #1108 😄
If you could check out my branch, build from source and verify that it works as you'd expect that'd be great. I'll merge after I giving it a more in-depth try but I think it should be enough.
Was support added in #1106? I can't get it to work with the following config:
let g:LanguageClient_serverCommands = {
\ 'rust': {
\ 'name': 'rust-analyzer',
\ 'command': ['rust-analyzer'],
\ 'initializationOptions' : {
\ 'inlayHints': {
\ 'enable': v:true,
\ 'chainingHints': v:true
\ }
\ },
\ },
\}
@ibraheemdev it works for me with that exact configuration. Which version of rust-analyzer and language-client-neovim are you using?
@martskins I built rust-analyzer from master and languageclient-neovim from next
:
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
rust-analyzer.inlayHints
are working for me with coc.nvim.
I see the same behaviour if I compile rust-analyzer from master. Latest release worked for me though, so maybe worth asking in rust-analyzer if something changed in master regarding chaining hints or if maybe you need to do something else to get those when compiling yourself.
@akhilman @ibraheemdev @martskins not sure it's still relevant, but I also had troubles with getting chainingHints
working. Sadly, there's no much information on the Internet about LanguageClient-neovim
. Everyone on this planet seems to succumb either to VSCode
or to coc.nvim
. I refuse to use coc.nvim
because I don't want to pollute my computer with JavaScript/node_modules/webdev crap just to get Rust autocompletion working.
Finally, it works.
As you can see, I use next
branch of LanguageClient-neovim
:
This is my ~/.config/nvim/settings.json
:
{
"rust-analyzer": {
"checkOnSave": {
"extraArgs": ["--target-dir", "/home/artur/.cache/rust-analyzer"]
},
"rustfmt": {
"overrideCommand": ["rustfmt"]
},
"diagnostics": {
"enable": true
},
"inlayHints": {
"enable": true,
"chainingHints": true,
"typeHints": true,
"parameterHints": true
}
}
}
And this is the part of ~/.config/nvim/init.vim
which is reponsible for LanguageClient-neovim
:
call plug#begin()
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'sh install.sh',
\ }
let g:LanguageClient_serverCommands = {
\ 'rust': ['rust-analyzer'],
\ 'c': ['clangd'],
\ 'cpp': ['clangd'],
\}
let g:LanguageClient_settingsPath = expand('~/.config/nvim/settings.json')
let g:LanguageClient_loggingFile = expand('~/.config/nvim/LanguageClient.log')
let g:LanguageClient_loggingLevel = 'DEBUG'
P. S. Sorry if my comment offends JavaScript/webdev fans
Are there any plans to implement something like this: https://github.com/fannheyward/coc-rust-analyzer/issues/394#issuecomment-742273063 Looks like a reasonable trade-off until https://github.com/neovim/neovim/pull/9496 is finished.
@Logarithmus that is actually what #1108 implements, unless I misunderstood what you meant. I think the issue you are having though is due to using an incorrect settings.json
. Try changing rust-analyzer
in the root of your settings.json
to initializationOptions
, if that doesn't work please open an issue and I can help you solve that.
@Logarithmus that is actually what #1108 implements, unless I misunderstood what you meant. I think the issue you are having though is due to using an incorrect
settings.json
. Try changingrust-analyzer
in the root of yoursettings.json
toinitializationOptions
, if that doesn't work please open an issue and I can help you solve that.
I meant TypeHint
s & ParameterHint
s. Currently LanguageClient-neovim
only supports displaying ChainingHint
s.
In comparison, coc-rust-analyzer
implements both ChainingHint
s & TypeHint
s: https://github.com/fannheyward/coc-rust-analyzer/issues/394#issuecomment-742273063. TypeHint
s which are located on the same line are joined into single hint and then displayed at the end of line.
Oh I see, I guess it would be a decent addition. I for one find it too distracting, but I guess it's a nice middleground for people that want that.