aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-01-11 01:16:15 -0800
committerGitHub <noreply@github.com>2021-01-11 01:16:15 -0800
commit091227fed13f567e6d2281c15678ec0d509bb11b (patch)
treeeeb92e40f515dc25fbb9f35f7cf30801d3713319
parentMerge pull request #655 from ckipp01/metals (diff)
parent[docgen] Update README.md (diff)
downloadnvim-lspconfig-091227fed13f567e6d2281c15678ec0d509bb11b.tar
nvim-lspconfig-091227fed13f567e6d2281c15678ec0d509bb11b.tar.gz
nvim-lspconfig-091227fed13f567e6d2281c15678ec0d509bb11b.tar.bz2
nvim-lspconfig-091227fed13f567e6d2281c15678ec0d509bb11b.tar.lz
nvim-lspconfig-091227fed13f567e6d2281c15678ec0d509bb11b.tar.xz
nvim-lspconfig-091227fed13f567e6d2281c15678ec0d509bb11b.tar.zst
nvim-lspconfig-091227fed13f567e6d2281c15678ec0d509bb11b.zip
Merge pull request #657 from mjlbach/fix_rust_analyzer_root
rust_analyzer: read project root from cargo
-rw-r--r--CONFIG.md92
-rw-r--r--lua/lspconfig/rust_analyzer.lua12
2 files changed, 9 insertions, 95 deletions
diff --git a/CONFIG.md b/CONFIG.md
index b3c3cb1c..550b1353 100644
--- a/CONFIG.md
+++ b/CONFIG.md
@@ -2423,98 +2423,6 @@ cs bootstrap \
-o /usr/local/bin/metals -f
```
-This server accepts configuration via the `settings` key.
-<details><summary>Available settings:</summary>
-
-- **`metals.ammoniteJvmProperties`**: `array`
-
- Array items: `{type = "string"}`
-
- null
-
-- **`metals.bloopSbtAlreadyInstalled`**: `boolean`
-
- null
-
-- **`metals.bloopVersion`**: `string`
-
- null
-
-- **`metals.customRepositories`**: `array`
-
- Array items: `{type = "string"}`
-
- null
-
-- **`metals.enableStripMarginOnTypeFormatting`**: `boolean`
-
- Default: `true`
-
- null
-
-- **`metals.excludedPackages`**: `array`
-
- Default: `{}`
-
- null
-
-- **`metals.gradleScript`**: `string`
-
- null
-
-- **`metals.javaHome`**: `string`
-
- null
-
-- **`metals.mavenScript`**: `string`
-
- null
-
-- **`metals.millScript`**: `string`
-
- null
-
-- **`metals.sbtScript`**: `string`
-
- null
-
-- **`metals.scalafixConfigPath`**: `string`
-
- null
-
-- **`metals.scalafmtConfigPath`**: `string`
-
- null
-
-- **`metals.serverProperties`**: `array`
-
- Array items: `{type = "string"}`
-
- null
-
-- **`metals.serverVersion`**: `string`
-
- Default: `"0.9.8"`
-
- null
-
-- **`metals.showImplicitArguments`**: `boolean`
-
- null
-
-- **`metals.showImplicitConversionsAndClasses`**: `boolean`
-
- null
-
-- **`metals.showInferredType`**: `boolean`
-
- null
-
-- **`metals.superMethodLensesEnabled`**: `boolean`
-
- Enable\/disable goto super method code lens\.
-
-</details>
```lua
require'lspconfig'.metals.setup{}
diff --git a/lua/lspconfig/rust_analyzer.lua b/lua/lspconfig/rust_analyzer.lua
index 1ff1370a..6ba704b3 100644
--- a/lua/lspconfig/rust_analyzer.lua
+++ b/lua/lspconfig/rust_analyzer.lua
@@ -6,9 +6,15 @@ configs.rust_analyzer = {
cmd = {"rust-analyzer"};
filetypes = {"rust"};
root_dir = function(fname)
- return util.find_git_ancestor(fname) or
- util.root_pattern("rust-project.json")(fname) or
- util.root_pattern("Cargo.toml")(fname)
+ local cargo_metadata = vim.fn.system("cargo metadata --format-version 1")
+ local cargo_root = nil
+ if vim.v.shell_handler == 0 then
+ cargo_root = vim.fn.json_decode(cargo_metadata)["workspace_root"]
+ end
+ return cargo_root or
+ util.find_git_ancestor(fname) or
+ util.root_pattern("rust-project.json")(fname) or
+ util.root_pattern("Cargo.toml")(fname)
end;
settings = {
["rust-analyzer"] = {}