diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 16e1a2f54490..525ec90179bb 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -505,6 +505,11 @@ config_data! { /// Internal config, path to proc-macro server executable. procMacro_server: Option = "null", + /// Configures the level of detail rust-analyzer will report while scanning files. + /// + /// If not set, this will default to including parent directories while scanning. + progressReporting_verbosity: Vec = "[]", + /// Exclude imports from find-all-references. references_excludeImports: bool = "false", @@ -1237,6 +1242,10 @@ impl Config { } } + pub fn progress_reporting(&self) -> &[ProgressReportingConfig] { + &self.data.progressReporting_verbosity + } + pub fn cargo_autoreload(&self) -> bool { self.data.cargo_autoreload } @@ -1882,6 +1891,7 @@ mod de_unit_v { named_unit_variant!(decimal); named_unit_variant!(hexadecimal); named_unit_variant!(both); + named_unit_variant!(include_directory); } #[derive(Deserialize, Debug, Clone, Copy)] @@ -2121,6 +2131,14 @@ pub enum MemoryLayoutHoverRenderKindDef { Both, } +#[derive(Deserialize, Debug, Clone, PartialEq)] +#[serde(rename_all = "snake_case")] +#[serde(untagged)] +pub enum ProgressReportingConfig { + #[serde(deserialize_with = "de_unit_v::include_directory")] + IncludeDirectory, +} + #[derive(Deserialize, Debug, Clone, PartialEq)] #[serde(rename_all = "snake_case")] #[serde(untagged)] @@ -2571,6 +2589,13 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json }, ], }, + "Vec" => set! { + "type": "string", + "enum": ["include_directory", ], + "enumDescriptions": [ + "`include_directory`: Include the directory of the files being indexed", + ] + }, _ => panic!("missing entry for {ty}: {default}"), } diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 72f6d0fde5fe..755d5e5de3e1 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -1,6 +1,6 @@ //! The main loop of `rust-analyzer` responsible for dispatching LSP //! requests/replies and notifications back to the client. -use crate::lsp::ext; +use crate::{config::ProgressReportingConfig, lsp::ext}; use std::{ fmt, time::{Duration, Instant}, @@ -633,14 +633,20 @@ impl GlobalState { let mut message = format!("{n_done}/{n_total}"); if let Some(dir) = dir { - message += &format!( - ": {}", - match dir.strip_prefix(self.config.root_path()) { - Some(relative_path) => relative_path.as_ref(), - None => dir.as_ref(), - } - .display() - ); + if self + .config + .progress_reporting() + .contains(&ProgressReportingConfig::IncludeDirectory) + { + message += &format!( + ": {}", + match dir.strip_prefix(self.config.root_path()) { + Some(relative_path) => relative_path.as_ref(), + None => dir.as_ref(), + } + .display() + ); + } } self.report_progress( diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc index da7654b0f644..91d0c3e2b220 100644 --- a/docs/user/generated_config.adoc +++ b/docs/user/generated_config.adoc @@ -793,6 +793,13 @@ This config takes a map of crate names with the exported proc-macro names to ign -- Internal config, path to proc-macro server executable. -- +[[rust-analyzer.progressReporting.verbosity]]rust-analyzer.progressReporting.verbosity (default: `[]`):: ++ +-- +Configures the level of detail rust-analyzer will report while scanning files. + +If not set, this will default to including parent directories while scanning. +-- [[rust-analyzer.references.excludeImports]]rust-analyzer.references.excludeImports (default: `false`):: + -- diff --git a/editors/code/package.json b/editors/code/package.json index 3a1df5a2f901..a6dad428fcc2 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -1517,6 +1517,17 @@ "string" ] }, + "rust-analyzer.progressReporting.verbosity": { + "markdownDescription": "Configures the level of detail rust-analyzer will report while scanning files.\n\nIf not set, this will default to including parent directories while scanning.", + "default": [], + "type": "string", + "enum": [ + "include_directory" + ], + "enumDescriptions": [ + "`include_directory`: Include the directory of the files being indexed" + ] + }, "rust-analyzer.references.excludeImports": { "markdownDescription": "Exclude imports from find-all-references.", "default": false,