Add config for proc_macro

This commit is contained in:
Edwin Cheng 2020-04-13 00:05:33 +08:00
parent 22e33f308a
commit a4b0ce07f8
5 changed files with 22 additions and 1 deletions

View file

@ -70,7 +70,7 @@ pub(crate) fn load_cargo(
})
.collect::<FxHashMap<_, _>>();
let proc_macro_client = if with_proc_macro {
let proc_macro_client = if !with_proc_macro {
ProcMacroClient::dummy()
} else {
ProcMacroClient::extern_process(Path::new("ra_proc_macro_srv")).unwrap()

View file

@ -131,6 +131,14 @@ impl Config {
set(value, "/cargo/allFeatures", &mut self.cargo.all_features);
set(value, "/cargo/features", &mut self.cargo.features);
set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check);
match get::<bool>(value, "/procMacro/enabled") {
Some(true) => {
set(value, "/procMacro/serverPath", &mut self.proc_macro_srv);
}
_ => self.proc_macro_srv = None,
}
match get::<Vec<String>>(value, "/rustfmt/overrideCommand") {
Some(mut args) if !args.is_empty() => {
let command = args.remove(0);

View file

@ -64,6 +64,7 @@ pub struct WorldState {
pub latest_requests: Arc<RwLock<LatestRequests>>,
pub flycheck: Option<Flycheck>,
pub diagnostics: DiagnosticCollection,
pub proc_macro_client: ProcMacroClient,
}
/// An immutable snapshot of the world's state at a point in time.
@ -192,6 +193,7 @@ impl WorldState {
latest_requests: Default::default(),
flycheck,
diagnostics: Default::default(),
proc_macro_client,
}
}

View file

@ -388,6 +388,16 @@
"description": "Enable logging of VS Code extensions itself",
"type": "boolean",
"default": false
},
"rust-analyzer.procMacro.enabled": {
"description": "Enable Proc macro support, cargo.loadOutDirsFromCheck must be enabled.",
"type": "boolean",
"default": false
},
"rust-analyzer.procMacro.serverPath": {
"description": "Proc macro server path",
"type": "string",
"default": "ra_proc_macro_srv"
}
}
},

View file

@ -12,6 +12,7 @@ export class Config {
private readonly requiresReloadOpts = [
"serverPath",
"cargo",
"procMacro",
"files",
"highlighting",
"updates.channel",