aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmerson Ford <emersontford@gmail.com>2024-07-23 22:37:02 -0700
committerGitHub <noreply@github.com>2024-07-24 13:37:02 +0800
commit3cceca5a79b66d735cbacbf05fa0bce5f8b716ca (patch)
tree4f710028bca2bd7038cce7bf4405b9fcd571721a
parentdocs: update server_configurations.md (diff)
downloadnvim-lspconfig-3cceca5a79b66d735cbacbf05fa0bce5f8b716ca.tar
nvim-lspconfig-3cceca5a79b66d735cbacbf05fa0bce5f8b716ca.tar.gz
nvim-lspconfig-3cceca5a79b66d735cbacbf05fa0bce5f8b716ca.tar.bz2
nvim-lspconfig-3cceca5a79b66d735cbacbf05fa0bce5f8b716ca.tar.lz
nvim-lspconfig-3cceca5a79b66d735cbacbf05fa0bce5f8b716ca.tar.xz
nvim-lspconfig-3cceca5a79b66d735cbacbf05fa0bce5f8b716ca.tar.zst
nvim-lspconfig-3cceca5a79b66d735cbacbf05fa0bce5f8b716ca.zip
fix(rust-analyzer) automatically populate `init_options` from `settings["rust-analyzer"]` (#3247)
* automatically populate `init_options` for rust-analyzer in accordance with the rust-analyzer docs
-rw-r--r--doc/server_configurations.md7
-rw-r--r--doc/server_configurations.txt7
-rw-r--r--lua/lspconfig/server_configurations/rust_analyzer.lua9
3 files changed, 23 insertions, 0 deletions
diff --git a/doc/server_configurations.md b/doc/server_configurations.md
index 12bd3b96..0b2af021 100644
--- a/doc/server_configurations.md
+++ b/doc/server_configurations.md
@@ -10180,6 +10180,9 @@ require'lspconfig'.rust_analyzer.setup{
}
}
```
+
+Note: do not set `init_options` for this LS config, it will be automatically populated by the contents of settings["rust-analyzer"] per
+https://github.com/rust-lang/rust-analyzer/blob/eb5da56d839ae0a9e9f50774fa3eb78eb0964550/docs/dev/lsp-extensions.md?plain=1#L26.
@@ -10191,6 +10194,10 @@ require'lspconfig'.rust_analyzer.setup{}
- CargoReload: Reload current cargo workspace
**Default values:**
+ - `before_init` :
+ ```lua
+ see source file
+ ```
- `capabilities` :
```lua
{
diff --git a/doc/server_configurations.txt b/doc/server_configurations.txt
index 12bd3b96..0b2af021 100644
--- a/doc/server_configurations.txt
+++ b/doc/server_configurations.txt
@@ -10180,6 +10180,9 @@ require'lspconfig'.rust_analyzer.setup{
}
}
```
+
+Note: do not set `init_options` for this LS config, it will be automatically populated by the contents of settings["rust-analyzer"] per
+https://github.com/rust-lang/rust-analyzer/blob/eb5da56d839ae0a9e9f50774fa3eb78eb0964550/docs/dev/lsp-extensions.md?plain=1#L26.
@@ -10191,6 +10194,10 @@ require'lspconfig'.rust_analyzer.setup{}
- CargoReload: Reload current cargo workspace
**Default values:**
+ - `before_init` :
+ ```lua
+ see source file
+ ```
- `capabilities` :
```lua
{
diff --git a/lua/lspconfig/server_configurations/rust_analyzer.lua b/lua/lspconfig/server_configurations/rust_analyzer.lua
index b89546a7..13a36207 100644
--- a/lua/lspconfig/server_configurations/rust_analyzer.lua
+++ b/lua/lspconfig/server_configurations/rust_analyzer.lua
@@ -77,6 +77,12 @@ return {
serverStatusNotification = true,
},
},
+ before_init = function(init_params, config)
+ -- See https://github.com/rust-lang/rust-analyzer/blob/eb5da56d839ae0a9e9f50774fa3eb78eb0964550/docs/dev/lsp-extensions.md?plain=1#L26
+ if config.settings and config.settings['rust-analyzer'] then
+ init_params.initializationOptions = config.settings['rust-analyzer']
+ end
+ end,
},
commands = {
CargoReload = {
@@ -105,6 +111,9 @@ require'lspconfig'.rust_analyzer.setup{
}
}
```
+
+Note: do not set `init_options` for this LS config, it will be automatically populated by the contents of settings["rust-analyzer"] per
+https://github.com/rust-lang/rust-analyzer/blob/eb5da56d839ae0a9e9f50774fa3eb78eb0964550/docs/dev/lsp-extensions.md?plain=1#L26.
]],
default_config = {
root_dir = [[root_pattern("Cargo.toml", "rust-project.json")]],