mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Merge #7451
7451: rust-analyzer.files.excludeDirs r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
0ebf548ab7
5 changed files with 34 additions and 12 deletions
|
@ -46,7 +46,7 @@ pub fn load_cargo(
|
||||||
vfs.file_id(&path)
|
vfs.file_id(&path)
|
||||||
});
|
});
|
||||||
|
|
||||||
let project_folders = ProjectFolders::new(&[ws]);
|
let project_folders = ProjectFolders::new(&[ws], &[]);
|
||||||
loader.set_config(vfs::loader::Config { load: project_folders.load, watch: vec![] });
|
loader.set_config(vfs::loader::Config { load: project_folders.load, watch: vec![] });
|
||||||
|
|
||||||
log::debug!("crate graph: {:?}", crate_graph);
|
log::debug!("crate graph: {:?}", crate_graph);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
//! configure the server itself, feature flags are passed into analysis, and
|
//! configure the server itself, feature flags are passed into analysis, and
|
||||||
//! tweak things like automatic insertion of `()` in completions.
|
//! tweak things like automatic insertion of `()` in completions.
|
||||||
|
|
||||||
use std::{convert::TryFrom, ffi::OsString, iter, path::PathBuf};
|
use std::{ffi::OsString, iter, path::PathBuf};
|
||||||
|
|
||||||
use flycheck::FlycheckConfig;
|
use flycheck::FlycheckConfig;
|
||||||
use hir::PrefixKind;
|
use hir::PrefixKind;
|
||||||
|
@ -105,6 +105,8 @@ config_data! {
|
||||||
|
|
||||||
/// Controls file watching implementation.
|
/// Controls file watching implementation.
|
||||||
files_watcher: String = "\"client\"",
|
files_watcher: String = "\"client\"",
|
||||||
|
/// These directories will be ignored by rust-analyzer.
|
||||||
|
files_excludeDirs: Vec<PathBuf> = "[]",
|
||||||
|
|
||||||
/// Whether to show `Debug` action. Only applies when
|
/// Whether to show `Debug` action. Only applies when
|
||||||
/// `#rust-analyzer.hoverActions.enable#` is set.
|
/// `#rust-analyzer.hoverActions.enable#` is set.
|
||||||
|
@ -248,7 +250,7 @@ impl LensConfig {
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FilesConfig {
|
pub struct FilesConfig {
|
||||||
pub watcher: FilesWatcher,
|
pub watcher: FilesWatcher,
|
||||||
pub exclude: Vec<String>,
|
pub exclude: Vec<AbsPathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -458,7 +460,7 @@ impl Config {
|
||||||
"notify" => FilesWatcher::Notify,
|
"notify" => FilesWatcher::Notify,
|
||||||
"client" | _ => FilesWatcher::Client,
|
"client" | _ => FilesWatcher::Client,
|
||||||
},
|
},
|
||||||
exclude: Vec::new(),
|
exclude: self.data.files_excludeDirs.iter().map(|it| self.root_path.join(it)).collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn notifications(&self) -> NotificationsConfig {
|
pub fn notifications(&self) -> NotificationsConfig {
|
||||||
|
@ -468,11 +470,7 @@ impl Config {
|
||||||
self.data.cargo_autoreload
|
self.data.cargo_autoreload
|
||||||
}
|
}
|
||||||
pub fn cargo(&self) -> CargoConfig {
|
pub fn cargo(&self) -> CargoConfig {
|
||||||
let rustc_source = self.data.rustcSource.clone().and_then(|it| {
|
let rustc_source = self.data.rustcSource.as_ref().map(|it| self.root_path.join(&it));
|
||||||
AbsPathBuf::try_from(it)
|
|
||||||
.map_err(|_| log::error!("rustc source directory must be an absolute path"))
|
|
||||||
.ok()
|
|
||||||
});
|
|
||||||
|
|
||||||
CargoConfig {
|
CargoConfig {
|
||||||
no_default_features: self.data.cargo_noDefaultFeatures,
|
no_default_features: self.data.cargo_noDefaultFeatures,
|
||||||
|
@ -767,6 +765,10 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": { "type": "string" },
|
"items": { "type": "string" },
|
||||||
},
|
},
|
||||||
|
"Vec<PathBuf>" => set! {
|
||||||
|
"type": "array",
|
||||||
|
"items": { "type": "string" },
|
||||||
|
},
|
||||||
"FxHashSet<String>" => set! {
|
"FxHashSet<String>" => set! {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": { "type": "string" },
|
"items": { "type": "string" },
|
||||||
|
|
|
@ -214,7 +214,8 @@ impl GlobalState {
|
||||||
|
|
||||||
let mut change = Change::new();
|
let mut change = Change::new();
|
||||||
|
|
||||||
let project_folders = ProjectFolders::new(&workspaces);
|
let files_config = self.config.files();
|
||||||
|
let project_folders = ProjectFolders::new(&workspaces, &files_config.exclude);
|
||||||
|
|
||||||
self.proc_macro_client = match self.config.proc_macro_srv() {
|
self.proc_macro_client = match self.config.proc_macro_srv() {
|
||||||
None => None,
|
None => None,
|
||||||
|
@ -231,7 +232,7 @@ impl GlobalState {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let watch = match self.config.files().watcher {
|
let watch = match files_config.watcher {
|
||||||
FilesWatcher::Client => vec![],
|
FilesWatcher::Client => vec![],
|
||||||
FilesWatcher::Notify => project_folders.watch,
|
FilesWatcher::Notify => project_folders.watch,
|
||||||
};
|
};
|
||||||
|
@ -319,7 +320,10 @@ pub(crate) struct ProjectFolders {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProjectFolders {
|
impl ProjectFolders {
|
||||||
pub(crate) fn new(workspaces: &[ProjectWorkspace]) -> ProjectFolders {
|
pub(crate) fn new(
|
||||||
|
workspaces: &[ProjectWorkspace],
|
||||||
|
global_excludes: &[AbsPathBuf],
|
||||||
|
) -> ProjectFolders {
|
||||||
let mut res = ProjectFolders::default();
|
let mut res = ProjectFolders::default();
|
||||||
let mut fsc = FileSetConfig::builder();
|
let mut fsc = FileSetConfig::builder();
|
||||||
let mut local_filesets = vec![];
|
let mut local_filesets = vec![];
|
||||||
|
@ -333,6 +337,12 @@ impl ProjectFolders {
|
||||||
dirs.extensions.push("rs".into());
|
dirs.extensions.push("rs".into());
|
||||||
dirs.include.extend(root.include);
|
dirs.include.extend(root.include);
|
||||||
dirs.exclude.extend(root.exclude);
|
dirs.exclude.extend(root.exclude);
|
||||||
|
for excl in global_excludes {
|
||||||
|
if dirs.include.iter().any(|incl| incl.starts_with(excl)) {
|
||||||
|
dirs.exclude.push(excl.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vfs::loader::Entry::Directories(dirs)
|
vfs::loader::Entry::Directories(dirs)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,8 @@
|
||||||
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`.
|
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`.
|
||||||
[[rust-analyzer.files.watcher]]rust-analyzer.files.watcher (default: `"client"`)::
|
[[rust-analyzer.files.watcher]]rust-analyzer.files.watcher (default: `"client"`)::
|
||||||
Controls file watching implementation.
|
Controls file watching implementation.
|
||||||
|
[[rust-analyzer.files.excludeDirs]]rust-analyzer.files.excludeDirs (default: `[]`)::
|
||||||
|
These directories will be ignored by rust-analyzer.
|
||||||
[[rust-analyzer.hoverActions.debug]]rust-analyzer.hoverActions.debug (default: `true`)::
|
[[rust-analyzer.hoverActions.debug]]rust-analyzer.hoverActions.debug (default: `true`)::
|
||||||
Whether to show `Debug` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.
|
Whether to show `Debug` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.
|
||||||
[[rust-analyzer.hoverActions.enable]]rust-analyzer.hoverActions.enable (default: `true`)::
|
[[rust-analyzer.hoverActions.enable]]rust-analyzer.hoverActions.enable (default: `true`)::
|
||||||
|
|
|
@ -555,6 +555,14 @@
|
||||||
"default": "client",
|
"default": "client",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"rust-analyzer.files.excludeDirs": {
|
||||||
|
"markdownDescription": "These directories will be ignored by rust-analyzer.",
|
||||||
|
"default": [],
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"rust-analyzer.hoverActions.debug": {
|
"rust-analyzer.hoverActions.debug": {
|
||||||
"markdownDescription": "Whether to show `Debug` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.",
|
"markdownDescription": "Whether to show `Debug` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.",
|
||||||
"default": true,
|
"default": true,
|
||||||
|
|
Loading…
Reference in a new issue