Skip to content

Commit a4b0ce0

Browse files
committed
Add config for proc_macro
1 parent 22e33f3 commit a4b0ce0

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

crates/rust-analyzer/src/cli/load_cargo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub(crate) fn load_cargo(
7070
})
7171
.collect::<FxHashMap<_, _>>();
7272

73-
let proc_macro_client = if with_proc_macro {
73+
let proc_macro_client = if !with_proc_macro {
7474
ProcMacroClient::dummy()
7575
} else {
7676
ProcMacroClient::extern_process(Path::new("ra_proc_macro_srv")).unwrap()

crates/rust-analyzer/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ impl Config {
131131
set(value, "/cargo/allFeatures", &mut self.cargo.all_features);
132132
set(value, "/cargo/features", &mut self.cargo.features);
133133
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+
134142
match get::<Vec<String>>(value, "/rustfmt/overrideCommand") {
135143
Some(mut args) if !args.is_empty() => {
136144
let command = args.remove(0);

crates/rust-analyzer/src/world.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub struct WorldState {
6464
pub latest_requests: Arc<RwLock<LatestRequests>>,
6565
pub flycheck: Option<Flycheck>,
6666
pub diagnostics: DiagnosticCollection,
67+
pub proc_macro_client: ProcMacroClient,
6768
}
6869

6970
/// An immutable snapshot of the world's state at a point in time.
@@ -192,6 +193,7 @@ impl WorldState {
192193
latest_requests: Default::default(),
193194
flycheck,
194195
diagnostics: Default::default(),
196+
proc_macro_client,
195197
}
196198
}
197199

editors/code/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,16 @@
388388
"description": "Enable logging of VS Code extensions itself",
389389
"type": "boolean",
390390
"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"
391401
}
392402
}
393403
},

editors/code/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class Config {
1212
private readonly requiresReloadOpts = [
1313
"serverPath",
1414
"cargo",
15+
"procMacro",
1516
"files",
1617
"highlighting",
1718
"updates.channel",

0 commit comments

Comments
 (0)