diff options
author | Edwin Cheng <[email protected]> | 2020-04-12 17:05:33 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-04-16 12:28:06 +0100 |
commit | a4b0ce07f80773146c72004befc77be4e576c677 (patch) | |
tree | 0dec04c4667033b0115fae3be51e1e1202869abd | |
parent | 22e33f308a7dfe924bf2d10f9041e91cec1349a0 (diff) |
Add config for proc_macro
-rw-r--r-- | crates/rust-analyzer/src/cli/load_cargo.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 8 | ||||
-rw-r--r-- | crates/rust-analyzer/src/world.rs | 2 | ||||
-rw-r--r-- | editors/code/package.json | 10 | ||||
-rw-r--r-- | editors/code/src/config.ts | 1 |
5 files changed, 22 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs index f70d92c7f..dfda488fb 100644 --- a/crates/rust-analyzer/src/cli/load_cargo.rs +++ b/crates/rust-analyzer/src/cli/load_cargo.rs | |||
@@ -70,7 +70,7 @@ pub(crate) fn load_cargo( | |||
70 | }) | 70 | }) |
71 | .collect::<FxHashMap<_, _>>(); | 71 | .collect::<FxHashMap<_, _>>(); |
72 | 72 | ||
73 | let proc_macro_client = if with_proc_macro { | 73 | let proc_macro_client = if !with_proc_macro { |
74 | ProcMacroClient::dummy() | 74 | ProcMacroClient::dummy() |
75 | } else { | 75 | } else { |
76 | ProcMacroClient::extern_process(Path::new("ra_proc_macro_srv")).unwrap() | 76 | ProcMacroClient::extern_process(Path::new("ra_proc_macro_srv")).unwrap() |
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 4734df16a..46a89b37e 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -131,6 +131,14 @@ impl Config { | |||
131 | set(value, "/cargo/allFeatures", &mut self.cargo.all_features); | 131 | set(value, "/cargo/allFeatures", &mut self.cargo.all_features); |
132 | set(value, "/cargo/features", &mut self.cargo.features); | 132 | set(value, "/cargo/features", &mut self.cargo.features); |
133 | set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); | 133 | set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); |
134 | |||
135 | match get::<bool>(value, "/procMacro/enabled") { | ||
136 | Some(true) => { | ||
137 | set(value, "/procMacro/serverPath", &mut self.proc_macro_srv); | ||
138 | } | ||
139 | _ => self.proc_macro_srv = None, | ||
140 | } | ||
141 | |||
134 | match get::<Vec<String>>(value, "/rustfmt/overrideCommand") { | 142 | match get::<Vec<String>>(value, "/rustfmt/overrideCommand") { |
135 | Some(mut args) if !args.is_empty() => { | 143 | Some(mut args) if !args.is_empty() => { |
136 | let command = args.remove(0); | 144 | let command = args.remove(0); |
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs index 6c42e1d76..b7142e83b 100644 --- a/crates/rust-analyzer/src/world.rs +++ b/crates/rust-analyzer/src/world.rs | |||
@@ -64,6 +64,7 @@ pub struct WorldState { | |||
64 | pub latest_requests: Arc<RwLock<LatestRequests>>, | 64 | pub latest_requests: Arc<RwLock<LatestRequests>>, |
65 | pub flycheck: Option<Flycheck>, | 65 | pub flycheck: Option<Flycheck>, |
66 | pub diagnostics: DiagnosticCollection, | 66 | pub diagnostics: DiagnosticCollection, |
67 | pub proc_macro_client: ProcMacroClient, | ||
67 | } | 68 | } |
68 | 69 | ||
69 | /// An immutable snapshot of the world's state at a point in time. | 70 | /// An immutable snapshot of the world's state at a point in time. |
@@ -192,6 +193,7 @@ impl WorldState { | |||
192 | latest_requests: Default::default(), | 193 | latest_requests: Default::default(), |
193 | flycheck, | 194 | flycheck, |
194 | diagnostics: Default::default(), | 195 | diagnostics: Default::default(), |
196 | proc_macro_client, | ||
195 | } | 197 | } |
196 | } | 198 | } |
197 | 199 | ||
diff --git a/editors/code/package.json b/editors/code/package.json index 5f73c8d83..d39a9b6d8 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -388,6 +388,16 @@ | |||
388 | "description": "Enable logging of VS Code extensions itself", | 388 | "description": "Enable logging of VS Code extensions itself", |
389 | "type": "boolean", | 389 | "type": "boolean", |
390 | "default": false | 390 | "default": false |
391 | }, | ||
392 | "rust-analyzer.procMacro.enabled": { | ||
393 | "description": "Enable Proc macro support, cargo.loadOutDirsFromCheck must be enabled.", | ||
394 | "type": "boolean", | ||
395 | "default": false | ||
396 | }, | ||
397 | "rust-analyzer.procMacro.serverPath": { | ||
398 | "description": "Proc macro server path", | ||
399 | "type": "string", | ||
400 | "default": "ra_proc_macro_srv" | ||
391 | } | 401 | } |
392 | } | 402 | } |
393 | }, | 403 | }, |
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 35a05131c..3b2eec8ba 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -12,6 +12,7 @@ export class Config { | |||
12 | private readonly requiresReloadOpts = [ | 12 | private readonly requiresReloadOpts = [ |
13 | "serverPath", | 13 | "serverPath", |
14 | "cargo", | 14 | "cargo", |
15 | "procMacro", | ||
15 | "files", | 16 | "files", |
16 | "highlighting", | 17 | "highlighting", |
17 | "updates.channel", | 18 | "updates.channel", |