From f66fbc9a9144313127a04f4c9aba63224a66bc30 Mon Sep 17 00:00:00 2001 From: Green-Avocado Date: Tue, 30 Nov 2021 22:12:56 -0800 Subject: [PATCH 1/6] move config into `.rust-ide/` --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index bdd00d9..392fdfb 100644 --- a/lib/index.js +++ b/lib/index.js @@ -472,7 +472,7 @@ class RustLanguageClient extends AutoLanguageClient { // Don't build straight after initialize, wait for first `workspace/didChangeConfiguration` params.initializationOptions.omitInitBuild = true - let rlsConfigPath = path.join(projectPath, "rust-analyzer.json") + let rlsConfigPath = path.join(projectPath, ".rust-ide/rust-analyzer.json") if (fs.existsSync(rlsConfigPath)) { try { From e84b0c0a681b314287dd2fb620b42725e9b1fbfc Mon Sep 17 00:00:00 2001 From: Green-Avocado Date: Tue, 30 Nov 2021 22:30:55 -0800 Subject: [PATCH 2/6] change dir name to `.ide-rust` to match plugin name --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 392fdfb..7832ec5 100644 --- a/lib/index.js +++ b/lib/index.js @@ -472,7 +472,7 @@ class RustLanguageClient extends AutoLanguageClient { // Don't build straight after initialize, wait for first `workspace/didChangeConfiguration` params.initializationOptions.omitInitBuild = true - let rlsConfigPath = path.join(projectPath, ".rust-ide/rust-analyzer.json") + let rlsConfigPath = path.join(projectPath, ".ide-rust/rust-analyzer.json") if (fs.existsSync(rlsConfigPath)) { try { From 63ad60871fa8ee9cadca9153e506f6fe72f3289f Mon Sep 17 00:00:00 2001 From: Green-Avocado Date: Tue, 30 Nov 2021 22:48:04 -0800 Subject: [PATCH 3/6] add readme instructions with example --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index f7afaff..fbb8947 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,27 @@ NOTE: On Windows, you can install it using [choco](https://chocolatey.org/instal No other packages or manual setup is required as these will be handled with user prompts after install. However, you may wish to install `rustup` with your OS package manager instead of following prompts to install via [rustup.rs](https://rustup.rs). +## Configure rust-analyzer + +**rust-analyzer** settings can be stored in a JSON file located at `.ide-rust/rust-analyzer.json` relative to the project directory. + +### Example + +`.ide-rust/rust-analyzer.json` + +```json +{ + "cargo": { + "loadOutDirsFromCheck": true, + }, + "procMacro": { + "enable": true, + } +} +``` + +Refer to the [rust-analyzer User Manual](https://rust-analyzer.github.io/manual.html#configuration) for the supported config options. + ## Commands - `ide-rust:restart-all-language-servers` Restart all currently active Rls processes From 6f135bcadcdedfa70d675aa95e0338b44bb7985f Mon Sep 17 00:00:00 2001 From: Green-Avocado Date: Wed, 1 Dec 2021 21:08:05 -0800 Subject: [PATCH 4/6] reset path to project root --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 7832ec5..bdd00d9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -472,7 +472,7 @@ class RustLanguageClient extends AutoLanguageClient { // Don't build straight after initialize, wait for first `workspace/didChangeConfiguration` params.initializationOptions.omitInitBuild = true - let rlsConfigPath = path.join(projectPath, ".ide-rust/rust-analyzer.json") + let rlsConfigPath = path.join(projectPath, "rust-analyzer.json") if (fs.existsSync(rlsConfigPath)) { try { From aedf1f31efad81bef646c668214278e0fdc0391f Mon Sep 17 00:00:00 2001 From: Green-Avocado Date: Wed, 1 Dec 2021 21:08:24 -0800 Subject: [PATCH 5/6] use .config/rust-analyzer.json as fallback path --- lib/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/index.js b/lib/index.js index bdd00d9..d29a16a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -474,6 +474,10 @@ class RustLanguageClient extends AutoLanguageClient { let rlsConfigPath = path.join(projectPath, "rust-analyzer.json") + if (!fs.existsSync(rlsConfigPath)) { + rlsConfigPath = path.join(projectPath, ".config/rust-analyzer.json") + } + if (fs.existsSync(rlsConfigPath)) { try { let options = fs.readFileSync(rlsConfigPath) From b59f04a6197d8987e848320226e977c962d37874 Mon Sep 17 00:00:00 2001 From: Green-Avocado Date: Wed, 1 Dec 2021 21:35:44 -0800 Subject: [PATCH 6/6] update docs to reflect path changes --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fbb8947..599187c 100644 --- a/README.md +++ b/README.md @@ -36,11 +36,14 @@ However, you may wish to install `rustup` with your OS package manager instead o ## Configure rust-analyzer -**rust-analyzer** settings can be stored in a JSON file located at `.ide-rust/rust-analyzer.json` relative to the project directory. +**rust-analyzer** settings can be stored in a JSON file in the project directory. + +It first looks for `rust-analyzer.json`. +If the file does not exists, it then checks `.config/rust-analyzer.json`. ### Example -`.ide-rust/rust-analyzer.json` +`.config/rust-analyzer.json` ```json {