From 0f90e9fbd3f2546f90e9b515fd44522e59916849 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Mon, 11 Jan 2021 00:40:06 -0800 Subject: rust_analyzer: read project root from cargo --- lua/lspconfig/rust_analyzer.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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"] = {} -- cgit v1.2.3-70-g09d2 From d669fef7f1200369504287b4e3e7272b0b3b0811 Mon Sep 17 00:00:00 2001 From: Github Actions Date: Mon, 11 Jan 2021 09:01:23 +0000 Subject: [docgen] Update README.md skip-checks: true --- CONFIG.md | 92 --------------------------------------------------------------- 1 file changed, 92 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. -
Available settings: - -- **`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\. - -
```lua require'lspconfig'.metals.setup{} -- cgit v1.2.3-70-g09d2