aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/rust-analyzer/src/cli/load_cargo.rs2
-rw-r--r--crates/rust-analyzer/src/config.rs10
-rw-r--r--crates/rust-analyzer/src/reload.rs16
-rw-r--r--docs/user/generated_config.adoc2
-rw-r--r--editors/code/package.json8
5 files changed, 32 insertions, 6 deletions
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs
index 16ccab781..dbab4f5f4 100644
--- a/crates/rust-analyzer/src/cli/load_cargo.rs
+++ b/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -46,7 +46,7 @@ pub fn load_cargo(
46 vfs.file_id(&path) 46 vfs.file_id(&path)
47 }); 47 });
48 48
49 let project_folders = ProjectFolders::new(&[ws]); 49 let project_folders = ProjectFolders::new(&[ws], &[]);
50 loader.set_config(vfs::loader::Config { load: project_folders.load, watch: vec![] }); 50 loader.set_config(vfs::loader::Config { load: project_folders.load, watch: vec![] });
51 51
52 log::debug!("crate graph: {:?}", crate_graph); 52 log::debug!("crate graph: {:?}", crate_graph);
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index c135913e2..37487b6ac 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -105,6 +105,8 @@ config_data! {
105 105
106 /// Controls file watching implementation. 106 /// Controls file watching implementation.
107 files_watcher: String = "\"client\"", 107 files_watcher: String = "\"client\"",
108 /// These directories will be ignored by rust-analyzer.
109 files_excludeDirs: Vec<PathBuf> = "[]",
108 110
109 /// Whether to show `Debug` action. Only applies when 111 /// Whether to show `Debug` action. Only applies when
110 /// `#rust-analyzer.hoverActions.enable#` is set. 112 /// `#rust-analyzer.hoverActions.enable#` is set.
@@ -248,7 +250,7 @@ impl LensConfig {
248#[derive(Debug, Clone)] 250#[derive(Debug, Clone)]
249pub struct FilesConfig { 251pub struct FilesConfig {
250 pub watcher: FilesWatcher, 252 pub watcher: FilesWatcher,
251 pub exclude: Vec<String>, 253 pub exclude: Vec<AbsPathBuf>,
252} 254}
253 255
254#[derive(Debug, Clone)] 256#[derive(Debug, Clone)]
@@ -458,7 +460,7 @@ impl Config {
458 "notify" => FilesWatcher::Notify, 460 "notify" => FilesWatcher::Notify,
459 "client" | _ => FilesWatcher::Client, 461 "client" | _ => FilesWatcher::Client,
460 }, 462 },
461 exclude: Vec::new(), 463 exclude: self.data.files_excludeDirs.iter().map(|it| self.root_path.join(it)).collect(),
462 } 464 }
463 } 465 }
464 pub fn notifications(&self) -> NotificationsConfig { 466 pub fn notifications(&self) -> NotificationsConfig {
@@ -763,6 +765,10 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
763 "type": "array", 765 "type": "array",
764 "items": { "type": "string" }, 766 "items": { "type": "string" },
765 }, 767 },
768 "Vec<PathBuf>" => set! {
769 "type": "array",
770 "items": { "type": "string" },
771 },
766 "FxHashSet<String>" => set! { 772 "FxHashSet<String>" => set! {
767 "type": "array", 773 "type": "array",
768 "items": { "type": "string" }, 774 "items": { "type": "string" },
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index dabfb4241..0507186dc 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -214,7 +214,8 @@ impl GlobalState {
214 214
215 let mut change = Change::new(); 215 let mut change = Change::new();
216 216
217 let project_folders = ProjectFolders::new(&workspaces); 217 let files_config = self.config.files();
218 let project_folders = ProjectFolders::new(&workspaces, &files_config.exclude);
218 219
219 self.proc_macro_client = match self.config.proc_macro_srv() { 220 self.proc_macro_client = match self.config.proc_macro_srv() {
220 None => None, 221 None => None,
@@ -231,7 +232,7 @@ impl GlobalState {
231 }, 232 },
232 }; 233 };
233 234
234 let watch = match self.config.files().watcher { 235 let watch = match files_config.watcher {
235 FilesWatcher::Client => vec![], 236 FilesWatcher::Client => vec![],
236 FilesWatcher::Notify => project_folders.watch, 237 FilesWatcher::Notify => project_folders.watch,
237 }; 238 };
@@ -319,7 +320,10 @@ pub(crate) struct ProjectFolders {
319} 320}
320 321
321impl ProjectFolders { 322impl ProjectFolders {
322 pub(crate) fn new(workspaces: &[ProjectWorkspace]) -> ProjectFolders { 323 pub(crate) fn new(
324 workspaces: &[ProjectWorkspace],
325 global_excludes: &[AbsPathBuf],
326 ) -> ProjectFolders {
323 let mut res = ProjectFolders::default(); 327 let mut res = ProjectFolders::default();
324 let mut fsc = FileSetConfig::builder(); 328 let mut fsc = FileSetConfig::builder();
325 let mut local_filesets = vec![]; 329 let mut local_filesets = vec![];
@@ -333,6 +337,12 @@ impl ProjectFolders {
333 dirs.extensions.push("rs".into()); 337 dirs.extensions.push("rs".into());
334 dirs.include.extend(root.include); 338 dirs.include.extend(root.include);
335 dirs.exclude.extend(root.exclude); 339 dirs.exclude.extend(root.exclude);
340 for excl in global_excludes {
341 if dirs.include.iter().any(|incl| incl.starts_with(excl)) {
342 dirs.exclude.push(excl.clone());
343 }
344 }
345
336 vfs::loader::Entry::Directories(dirs) 346 vfs::loader::Entry::Directories(dirs)
337 }; 347 };
338 348
diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc
index 1974082da..55178c84c 100644
--- a/docs/user/generated_config.adoc
+++ b/docs/user/generated_config.adoc
@@ -56,6 +56,8 @@
56 List of warnings that should be displayed with hint severity.\n\nThe warnings will be indicated by faded text or three dots in code and will not show up in the `Problems Panel`. 56 List of warnings that should be displayed with hint severity.\n\nThe warnings will be indicated by faded text or three dots in code and will not show up in the `Problems Panel`.
57[[rust-analyzer.files.watcher]]rust-analyzer.files.watcher (default: `"client"`):: 57[[rust-analyzer.files.watcher]]rust-analyzer.files.watcher (default: `"client"`)::
58 Controls file watching implementation. 58 Controls file watching implementation.
59[[rust-analyzer.files.excludeDirs]]rust-analyzer.files.excludeDirs (default: `[]`)::
60 These directories will be ignored by rust-analyzer.
59[[rust-analyzer.hoverActions.debug]]rust-analyzer.hoverActions.debug (default: `true`):: 61[[rust-analyzer.hoverActions.debug]]rust-analyzer.hoverActions.debug (default: `true`)::
60 Whether to show `Debug` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set. 62 Whether to show `Debug` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.
61[[rust-analyzer.hoverActions.enable]]rust-analyzer.hoverActions.enable (default: `true`):: 63[[rust-analyzer.hoverActions.enable]]rust-analyzer.hoverActions.enable (default: `true`)::
diff --git a/editors/code/package.json b/editors/code/package.json
index ee54638f1..66af94186 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -555,6 +555,14 @@
555 "default": "client", 555 "default": "client",
556 "type": "string" 556 "type": "string"
557 }, 557 },
558 "rust-analyzer.files.excludeDirs": {
559 "markdownDescription": "These directories will be ignored by rust-analyzer.",
560 "default": [],
561 "type": "array",
562 "items": {
563 "type": "string"
564 }
565 },
558 "rust-analyzer.hoverActions.debug": { 566 "rust-analyzer.hoverActions.debug": {
559 "markdownDescription": "Whether to show `Debug` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.", 567 "markdownDescription": "Whether to show `Debug` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.",
560 "default": true, 568 "default": true,