Unnamed repository; edit this file 'description' to name the repository.
add num process in config
bit-aloo 3 months ago
parent 7767fe7 · commit dbe6b39
-rw-r--r--crates/rust-analyzer/src/config.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 28ac94e4de..cb6552c32f 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -380,6 +380,8 @@ config_data! {
/// The number of worker threads in the main loop. The default `null` means to pick
/// automatically.
numThreads: Option<NumThreads> = None,
+ /// The number of proc-macro-srv processes
+ proc_macro_processes: NumProcesses = NumProcesses::Concrete(1),
/// Expand attribute macros. Requires `#rust-analyzer.procMacro.enable#` to be set.
procMacro_attributes_enable: bool = true,
@@ -2641,6 +2643,13 @@ impl Config {
}
}
+ pub fn proc_macro_num_processes(&self) -> usize {
+ match self.proc_macro_processes() {
+ NumProcesses::Concrete(0) | NumProcesses::Physical => num_cpus::get_physical(),
+ &NumProcesses::Concrete(n) => n,
+ }
+ }
+
pub fn main_loop_num_threads(&self) -> usize {
match self.numThreads() {
Some(NumThreads::Concrete(0)) | None | Some(NumThreads::Physical) => {
@@ -3077,6 +3086,14 @@ pub enum NumThreads {
Concrete(usize),
}
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
+#[serde(rename_all = "snake_case")]
+pub enum NumProcesses {
+ Physical,
+ #[serde(untagged)]
+ Concrete(usize),
+}
+
macro_rules! _default_val {
($default:expr, $ty:ty) => {{
let default_: $ty = $default;