Skip to content

Update neovim instructions for neovim 0.11+#2814

Open
erfanio wants to merge 1 commit intorust-lang:mainfrom
erfanio:main
Open

Update neovim instructions for neovim 0.11+#2814
erfanio wants to merge 1 commit intorust-lang:mainfrom
erfanio:main

Conversation

@erfanio
Copy link
Copy Markdown

@erfanio erfanio commented Mar 31, 2026

  • Adding a bit structure to the different options for neovim.
  • Adding a note about neovim 0.11 displaying a warning when using neoconf.nvim
  • Updated the custom lua script to work with HEAD of rust and neovim 0.11

This doc points to rust-analyzer book instructions for nvim lsp which is also being updated in rust-lang/rust-analyzer#21924

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 31, 2026

Thanks for the PR. If you have write access, feel free to merge this PR if it does not need reviews. You can request a review using r? rustc-dev-guide or r? <username>.

@rustbot rustbot added the S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content label Mar 31, 2026
@erfanio
Copy link
Copy Markdown
Author

erfanio commented Mar 31, 2026

r? rustc-dev-guide

Copy link
Copy Markdown
Member

@reddevilmidzy reddevilmidzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! some nit and some question:)

View changes since this review

Comment on lines +149 to +159
1. The easiest way is using [neoconf.nvim](https://github.com/folke/neoconf.nvim/) but it uses the
deprecated `require('lspconfig')` API which displays a warning on neovim 0.11+.
2. Using `coc.nvim` is another option but it requires node.js to be installed.
3. Using a custom script to load rust-analyzer settings.

#### neoconf.nvim

[neoconf.nvim](https://github.com/folke/neoconf.nvim/) allows for project-local configuration
files with the native LSP. The steps for how to use it are below. Note that they require
rust-analyzer to already be configured with Neovim. Steps for this can be
[found here](https://rust-analyzer.github.io/book/other_editors.html#nvim-lsp).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. The easiest way is using [neoconf.nvim](https://github.com/folke/neoconf.nvim/) but it uses the
deprecated `require('lspconfig')` API which displays a warning on neovim 0.11+.
2. Using `coc.nvim` is another option but it requires node.js to be installed.
3. Using a custom script to load rust-analyzer settings.
#### neoconf.nvim
[neoconf.nvim](https://github.com/folke/neoconf.nvim/) allows for project-local configuration
files with the native LSP. The steps for how to use it are below. Note that they require
rust-analyzer to already be configured with Neovim. Steps for this can be
[found here](https://rust-analyzer.github.io/book/other_editors.html#nvim-lsp).
1. The easiest way is using [neoconf.nvim] but it uses the
deprecated `require('lspconfig')` API which displays a warning on neovim 0.11+.
2. Using `coc.nvim` is another option but it requires node.js to be installed.
3. Using a custom script to load rust-analyzer settings.
#### neoconf.nvim
[neoconf.nvim] allows for project-local configuration
files with the native LSP. The steps for how to use it are below. Note that they require
rust-analyzer to already be configured with Neovim. Steps for this can be
[found here](https://rust-analyzer.github.io/book/other_editors.html#nvim-lsp).
[neoconf.nvim]: https://github.com/folke/neoconf.nvim/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels a bit strange to make a suggestion via GitHub suggest, so...

could you please change it so that the references to https://github.com/folke/neoconf.nvim/ and https://rust-analyzer.github.io/book/other_editors.html#nvim-lsp
are placed at the end of the line and then applied?

like

[neoconf.nvim] allows for project-local configuration
files with the native LSP. The steps for how to use it are below. Note that they require
rust-analyzer to already be configured with Neovim. Steps for this can be
[found here][r-a nvim lsp].

(...)

1. Make sure rust-analyzer [LSP][r-a nvim lsp] is set up 

(...)

[neoconf.nvim]: https://github.com/folke/neoconf.nvim/
[r-a nvim lsp]: https://rust-analyzer.github.io/book/other_editors.html#nvim-lsp

If a link is referenced multiple times, I think it would be better to manage it this way.

client.config.settings["rust-analyzer"] = expand_config_variables(json.lsp["rust-analyzer"].initialization_options)
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
before_init = function(init_params, config)
-- When inside rust_lang/rust, we need to use the special rust_analyzer settings.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- When inside rust_lang/rust, we need to use the special rust_analyzer settings.
-- When inside rust-lang/rust, we need to use the special rust_analyzer settings.

vim.lsp.config('rust_analyzer', {
cmd = { 'rust-analyzer' },
filetypes = { 'rust' },
-- To support rust_lang/rust, we need to detect when we're in the rust repo and use the git root
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- To support rust_lang/rust, we need to detect when we're in the rust repo and use the git root
-- To support rust-lang/rust, we need to detect when we're in the rust repo and use the git root

local default_root_dir = vim.lsp.config['rust_analyzer'].root_dir
local default_before_init = vim.lsp.config['rust_analyzer'].before_init

vim.lsp.config('rust_analyzer', {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with Lua, so is it correct that there is a difference between _ and - in vim.lsp.config('rust_analyzer', {, cmd = { 'rust-analyzer' },, config.settings["rust-analyzer"] = json.lsp["rust-analyzer"] and vim.lsp.enable('rust_analyzer')?

@reddevilmidzy reddevilmidzy added S-waiting-on-author Status: this PR is waiting for additional action by the OP and removed S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content labels Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: this PR is waiting for additional action by the OP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants