Skip to main content
Add a question about how others handle this use case.
Source Link

I work primarily in Rust where I don't have type information written in the file (the compiler infers the type information for me). I normally rely on the type inlay hints, and in the JetBrains IDEs that I used to use, I could control-click on the type in the hint to go to its definition.

With Neovim, I have my type inlay hints, and the go-to-definition functionality, but I don't have a way to trigger LSP actions on the type information, since it isn't real text in the source file.

Here's a small example of what I'm talking about:

fn main() { let a: i32 = 3; // ^---^ - type inlay hint, virtual text // - if my cursor is there, all LSP actions only // work on the variable itself, not the type } 

I'm looking for a way to trigger LSP actions (e.g. vim.lsp.buf.type_definition() and vim.lsp.buf.hover()) on the type information in inlay hints, or in the hover window. This would allow me to act on the type information that isn't written in the source file.

I've tried setting virtualedit to allow me to move my cursor inside the inlay hints, but this doesn't work. The LSP actions just work on the variable the hint is for, and not the type in the hint.

I've also tried triggering LSP actions within the hover window, but this doesn't work (presumably because the hover popup isn't attached to the LSP server).

Additionally, I've tried the Lspsaga plugin because it supposedly works for this purpose, but it didn't help. I still couldn't trigger LSP actions within its hover window.

I'm curious how other people handle this use case. I know that in most cases I can run Telescope or something similar to quickly search for the type, but I'm looking for a method that allows me to "chain" LSP actions on subsequent LSP popup windows, like I'm used to from other IDEs.

Any help would be appreciated!

I work primarily in Rust where I don't have type information written in the file (the compiler infers the type information for me). I normally rely on the type inlay hints, and in the JetBrains IDEs that I used to use, I could control-click on the type in the hint to go to its definition.

With Neovim, I have my type inlay hints, and the go-to-definition functionality, but I don't have a way to trigger LSP actions on the type information, since it isn't real text in the source file.

Here's a small example of what I'm talking about:

fn main() { let a: i32 = 3; // ^---^ - type inlay hint, virtual text // - if my cursor is there, all LSP actions only // work on the variable itself, not the type } 

I'm looking for a way to trigger LSP actions (e.g. vim.lsp.buf.type_definition() and vim.lsp.buf.hover()) on the type information in inlay hints, or in the hover window. This would allow me to act on the type information that isn't written in the source file.

I've tried setting virtualedit to allow me to move my cursor inside the inlay hints, but this doesn't work. The LSP actions just work on the variable the hint is for, and not the type in the hint.

I've also tried triggering LSP actions within the hover window, but this doesn't work (presumably because the hover popup isn't attached to the LSP server).

Additionally, I've tried the Lspsaga plugin because it supposedly works for this purpose, but it didn't help. I still couldn't trigger LSP actions within its hover window.

Any help would be appreciated!

I work primarily in Rust where I don't have type information written in the file (the compiler infers the type information for me). I normally rely on the type inlay hints, and in the JetBrains IDEs that I used to use, I could control-click on the type in the hint to go to its definition.

With Neovim, I have my type inlay hints, and the go-to-definition functionality, but I don't have a way to trigger LSP actions on the type information, since it isn't real text in the source file.

Here's a small example of what I'm talking about:

fn main() { let a: i32 = 3; // ^---^ - type inlay hint, virtual text // - if my cursor is there, all LSP actions only // work on the variable itself, not the type } 

I'm looking for a way to trigger LSP actions (e.g. vim.lsp.buf.type_definition() and vim.lsp.buf.hover()) on the type information in inlay hints, or in the hover window. This would allow me to act on the type information that isn't written in the source file.

I've tried setting virtualedit to allow me to move my cursor inside the inlay hints, but this doesn't work. The LSP actions just work on the variable the hint is for, and not the type in the hint.

I've also tried triggering LSP actions within the hover window, but this doesn't work (presumably because the hover popup isn't attached to the LSP server).

Additionally, I've tried the Lspsaga plugin because it supposedly works for this purpose, but it didn't help. I still couldn't trigger LSP actions within its hover window.

I'm curious how other people handle this use case. I know that in most cases I can run Telescope or something similar to quickly search for the type, but I'm looking for a method that allows me to "chain" LSP actions on subsequent LSP popup windows, like I'm used to from other IDEs.

Any help would be appreciated!

edited tags
Link
Friedrich
  • 4.8k
  • 1
  • 17
  • 32
Source Link

Activating LSP actions on type information that isn't present in the source file

I work primarily in Rust where I don't have type information written in the file (the compiler infers the type information for me). I normally rely on the type inlay hints, and in the JetBrains IDEs that I used to use, I could control-click on the type in the hint to go to its definition.

With Neovim, I have my type inlay hints, and the go-to-definition functionality, but I don't have a way to trigger LSP actions on the type information, since it isn't real text in the source file.

Here's a small example of what I'm talking about:

fn main() { let a: i32 = 3; // ^---^ - type inlay hint, virtual text // - if my cursor is there, all LSP actions only // work on the variable itself, not the type } 

I'm looking for a way to trigger LSP actions (e.g. vim.lsp.buf.type_definition() and vim.lsp.buf.hover()) on the type information in inlay hints, or in the hover window. This would allow me to act on the type information that isn't written in the source file.

I've tried setting virtualedit to allow me to move my cursor inside the inlay hints, but this doesn't work. The LSP actions just work on the variable the hint is for, and not the type in the hint.

I've also tried triggering LSP actions within the hover window, but this doesn't work (presumably because the hover popup isn't attached to the LSP server).

Additionally, I've tried the Lspsaga plugin because it supposedly works for this purpose, but it didn't help. I still couldn't trigger LSP actions within its hover window.

Any help would be appreciated!