diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/cli/load_cargo.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 18 | ||||
-rw-r--r-- | crates/rust-analyzer/src/reload.rs | 16 |
3 files changed, 24 insertions, 12 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 071fde64d..37487b6ac 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -7,7 +7,7 @@ | |||
7 | //! configure the server itself, feature flags are passed into analysis, and | 7 | //! configure the server itself, feature flags are passed into analysis, and |
8 | //! tweak things like automatic insertion of `()` in completions. | 8 | //! tweak things like automatic insertion of `()` in completions. |
9 | 9 | ||
10 | use std::{convert::TryFrom, ffi::OsString, iter, path::PathBuf}; | 10 | use std::{ffi::OsString, iter, path::PathBuf}; |
11 | 11 | ||
12 | use flycheck::FlycheckConfig; | 12 | use flycheck::FlycheckConfig; |
13 | use hir::PrefixKind; | 13 | use hir::PrefixKind; |
@@ -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)] |
249 | pub struct FilesConfig { | 251 | pub 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 { |
@@ -468,11 +470,7 @@ impl Config { | |||
468 | self.data.cargo_autoreload | 470 | self.data.cargo_autoreload |
469 | } | 471 | } |
470 | pub fn cargo(&self) -> CargoConfig { | 472 | pub fn cargo(&self) -> CargoConfig { |
471 | let rustc_source = self.data.rustcSource.clone().and_then(|it| { | 473 | let rustc_source = self.data.rustcSource.as_ref().map(|it| self.root_path.join(&it)); |
472 | AbsPathBuf::try_from(it) | ||
473 | .map_err(|_| log::error!("rustc source directory must be an absolute path")) | ||
474 | .ok() | ||
475 | }); | ||
476 | 474 | ||
477 | CargoConfig { | 475 | CargoConfig { |
478 | no_default_features: self.data.cargo_noDefaultFeatures, | 476 | no_default_features: self.data.cargo_noDefaultFeatures, |
@@ -767,6 +765,10 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json | |||
767 | "type": "array", | 765 | "type": "array", |
768 | "items": { "type": "string" }, | 766 | "items": { "type": "string" }, |
769 | }, | 767 | }, |
768 | "Vec<PathBuf>" => set! { | ||
769 | "type": "array", | ||
770 | "items": { "type": "string" }, | ||
771 | }, | ||
770 | "FxHashSet<String>" => set! { | 772 | "FxHashSet<String>" => set! { |
771 | "type": "array", | 773 | "type": "array", |
772 | "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 | ||
321 | impl ProjectFolders { | 322 | impl 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 | ||