mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Read rust-analyzer.toml files on startup
This commit is contained in:
parent
4afe0d5393
commit
e0db833082
3 changed files with 40 additions and 8 deletions
|
@ -15,7 +15,9 @@ use ide_db::{
|
|||
};
|
||||
use itertools::Itertools;
|
||||
use proc_macro_api::{MacroDylib, ProcMacroServer};
|
||||
use project_model::{CargoConfig, ManifestPath, PackageRoot, ProjectManifest, ProjectWorkspace};
|
||||
use project_model::{
|
||||
CargoConfig, ManifestPath, PackageRoot, ProjectManifest, ProjectWorkspace, ProjectWorkspaceKind,
|
||||
};
|
||||
use span::Span;
|
||||
use vfs::{file_set::FileSetConfig, loader::Handle, AbsPath, AbsPathBuf, VfsPath};
|
||||
|
||||
|
@ -238,15 +240,32 @@ impl ProjectFolders {
|
|||
|
||||
// register the workspace manifest as well, note that this currently causes duplicates for
|
||||
// non-virtual cargo workspaces! We ought to fix that
|
||||
for manifest in workspaces.iter().filter_map(|ws| ws.manifest().map(ManifestPath::as_ref)) {
|
||||
let file_set_roots: Vec<VfsPath> = vec![VfsPath::from(manifest.to_owned())];
|
||||
for ws in workspaces.iter() {
|
||||
let mut file_set_roots: Vec<VfsPath> = vec![];
|
||||
let mut entries = vec![];
|
||||
let mut register = false;
|
||||
|
||||
let entry = vfs::loader::Entry::Files(vec![manifest.to_owned()]);
|
||||
if let Some(manifest) = ws.manifest().map(ManifestPath::as_ref) {
|
||||
file_set_roots.push(VfsPath::from(manifest.to_owned()));
|
||||
entries.push(manifest.to_owned());
|
||||
register = true;
|
||||
}
|
||||
|
||||
res.watch.push(res.load.len());
|
||||
res.load.push(entry);
|
||||
local_filesets.push(fsc.len() as u64);
|
||||
fsc.add_file_set(file_set_roots)
|
||||
// In case of detached files we do **not** look for a rust-analyzer.toml.
|
||||
if !matches!(ws.kind, ProjectWorkspaceKind::DetachedFile { .. }) {
|
||||
let ws_root = ws.workspace_root();
|
||||
file_set_roots.push(VfsPath::from(ws_root.to_owned()));
|
||||
entries.push(ws_root.to_owned());
|
||||
register = true;
|
||||
}
|
||||
|
||||
if register {
|
||||
let entry = vfs::loader::Entry::Files(entries);
|
||||
res.watch.push(res.load.len());
|
||||
res.load.push(entry);
|
||||
local_filesets.push(fsc.len() as u64);
|
||||
fsc.add_file_set(file_set_roots)
|
||||
}
|
||||
}
|
||||
|
||||
let fsc = fsc.build();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue