Update neovim instructions for neovim 0.11+#2814
Update neovim instructions for neovim 0.11+#2814erfanio wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
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 |
| 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). |
There was a problem hiding this comment.
| 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/ |
There was a problem hiding this comment.
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-lspIf 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. |
There was a problem hiding this comment.
| -- 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 |
There was a problem hiding this comment.
| -- 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', { |
There was a problem hiding this comment.
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')?
rustand neovim 0.11This doc points to rust-analyzer book instructions for nvim lsp which is also being updated in rust-lang/rust-analyzer#21924