Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Can't get extension to work #20

Open
marcoths opened this issue Dec 22, 2020 · 9 comments
Open

Can't get extension to work #20

marcoths opened this issue Dec 22, 2020 · 9 comments

Comments

@marcoths
Copy link

Neovim version NVIM v0.5.0-dev+950-g5ce328df4

Loaded the plugin in ~/.local/share/nvim/site/pack/*/start/lsp_extensions.nvim

This is the folder structure

.
├── examples
│   ├── dart
│   │   ├── closing_labels.lua
│   │   └── outline.lua
│   └── inlay_hints_inline.lua
├── LICENSE
├── lua
│   └── lsp_extensions
│       ├── dart
│       │   ├── closing_labels.lua
│       │   └── outline.lua
│       ├── init.lua
│       ├── inlay_hints.lua
│       └── telescope_references.lua
└── README.md

and in my init.nvim looks like this:

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

But the type hints are not showing for Rust files - I have setup Rust analyzer as well, the build-in LSP features are working properly. Any idea on what else to look?

Many thanks

@thorlucas
Copy link

Having the same problem here. Inlay hints are not showing no matter what.

@PatOConnor43
Copy link
Contributor

PatOConnor43 commented Dec 26, 2020

Hi, can you try updating neovim and rust-analyzer? I tried reproducing the issue and it seems to work for me calling the lua function directly as well as using the autocommand. Something else that could be happening is that if you are expecting the inlay hints to appear immidiately upon opening the file, your lsp server may not be connected yet. However, given the autocommand you linked, as soon as you move your cursor the request will be made and you should see the hints. Hopefully that works for you.

@eminence
Copy link

I'm also having this issue, unfortunately. I'm using the latest version of neovim and rust-analyzer (the latest commits from github as of this writing). I should also have the latest neovim/nvim-lspconfig and nvim-lua/lsp_extensions.nvim (via running :PlugUpdate).

I'm testing this by loading up the following file in neovim:

struct Foo {
    a: u8,
    b: bool
}

pub fn foo() {
    let b = true;
    let _ = Foo {
        a: 0
    };
}

I have the following autocmd:

autocmd CursorHold,CursorHoldI *.rs :lua require'lsp_extensions'.inlay_hints{ only_current_line = true }

I know that rust-analyzer is connected because I see the error line 8 (about the missing field b). But it navigate my cursor to line 7 (let b = true;), I expect to see some inline type hint, but I don't see anything. Running :lua require'lsp_extensions'.inlay_hints{ only_current_line = true } manually also doesn't do anything.

@PatOConnor43
Copy link
Contributor

Where are you expecting there to be hints with this sample? My language server doesn't return any hints for this at all. Are you sure that you want to use only_current_line? If you're using that there could be other hints in the file but you could be looking at a line that doesn't have any hints.

@eminence
Copy link

I was expecting type hints on line 7 (which is let b = true). rust-analyzer with vscode will give me a hint that the variable b is type bool (since it is not explicitly typed, but can be inferred). So I expected neovim to do the same.

But maybe let's flip this around -- Can you give me a small sample that will provide hints? I'll test with your sample and can compare your output to what I see

Thanks!

@PatOConnor43
Copy link
Contributor

Ah okay. Neovim doesn't support virtual text in between text so by default the only hint type that is shown is "ChainingHint". You can enable "TypeHint" and "ParameterHint" by passing in an enabled table. That would look something like this:
:lua require'lsp_extensions'.inlay_hints{ prefix = '', highlight = "Comment", enabled = {"TypeHint", "ChainingHint", "ParameterHint"}}

Here is a related issue #14
If there are multiple hints on the same line then it looks like the first one is drawn and the others are ignored.

I was testing in rust-analyzer by the way.

@eminence
Copy link

Ah ha! I'm so sorry for the noise, then (I could have sworn that nvim used to supposed this, but clearly I am mis-remembering).

Using a better test, I am indeed seeing the ChainingHints, as expected. Thank you!

@PatOConnor43
Copy link
Contributor

No problem! This is probably something that could be made more obvious with documentation. Maybe I'll put up a PR tonight. Hopefully this is @marcoths 's issue as well.

@marcoths
Copy link
Author

@PatOConnor43 Yeah your suggestion also worked for me, many thanks! Didn't know those hints were not enabled by default

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

No branches or pull requests

4 participants