Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4585b46

Browse files
committed
Auto merge of rust-lang#16670 - rikhuijzer:rh/inlay-hints-nvim, r=Veykril
Document nvim 0.10 `inlay_hint` It took me a few hours to figure out how to enable inlay type hints on Nvim 0.10 with `lspconfig`. `rustaceanvim` has already dropped support for them (mrcjkb/rustaceanvim#46 (comment)) and most other plugins, like `rust-tools`, are depreciated in favor of `rustaceanvim`. This PR documents how to enable the inlay hints on Neovim 0.10 and later. I've tested this and changing the `on_attach` function is the only step that is required.
2 parents 309e087 + 4060377 commit 4585b46

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

docs/user/manual.adoc

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,14 @@ You can also pass LSP settings to the server:
337337
[source,vim]
338338
----
339339
lua << EOF
340-
local nvim_lsp = require'lspconfig'
340+
local lspconfig = require'lspconfig'
341341
342342
local on_attach = function(client)
343343
require'completion'.on_attach(client)
344344
end
345345
346-
nvim_lsp.rust_analyzer.setup({
347-
on_attach=on_attach,
346+
lspconfig.rust_analyzer.setup({
347+
on_attach = on_attach,
348348
settings = {
349349
["rust-analyzer"] = {
350350
imports = {
@@ -367,6 +367,19 @@ nvim_lsp.rust_analyzer.setup({
367367
EOF
368368
----
369369

370+
If you're running Neovim 0.10 or later, you can enable inlay hints via `on_attach`:
371+
372+
[source,vim]
373+
----
374+
lspconfig.rust_analyzer.setup({
375+
on_attach = function(client, bufnr)
376+
vim.lsp.inlay_hint.enable(bufnr)
377+
end
378+
})
379+
----
380+
381+
Note that the hints are only visible after `rust-analyzer` has finished loading **and** you have to edit the file to trigger a re-render.
382+
370383
See https://sharksforarms.dev/posts/neovim-rust/ for more tips on getting started.
371384

372385
Check out https://github.com/mrcjkb/rustaceanvim for a batteries included rust-analyzer setup for Neovim.

0 commit comments

Comments
 (0)