mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Allow disabling Cargo.toml not found error
This commit is contained in:
parent
6c321d7318
commit
e7bb82c3a4
4 changed files with 26 additions and 19 deletions
|
@ -56,6 +56,7 @@ impl Default for FeatureFlags {
|
||||||
("completion.insertion.add-call-parenthesis", true),
|
("completion.insertion.add-call-parenthesis", true),
|
||||||
("completion.enable-postfix", true),
|
("completion.enable-postfix", true),
|
||||||
("notifications.workspace-loaded", true),
|
("notifications.workspace-loaded", true),
|
||||||
|
("notifications.cargo-toml-not-found", true),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use lsp_types::{ClientCapabilities, NumberOrString};
|
||||||
use ra_cargo_watch::{CheckOptions, CheckTask};
|
use ra_cargo_watch::{CheckOptions, CheckTask};
|
||||||
use ra_ide::{Canceled, FeatureFlags, FileId, LibraryData, SourceRootId};
|
use ra_ide::{Canceled, FeatureFlags, FileId, LibraryData, SourceRootId};
|
||||||
use ra_prof::profile;
|
use ra_prof::profile;
|
||||||
|
use ra_project_model::WorkspaceError;
|
||||||
use ra_vfs::{VfsTask, Watch};
|
use ra_vfs::{VfsTask, Watch};
|
||||||
use relative_path::RelativePathBuf;
|
use relative_path::RelativePathBuf;
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
@ -62,6 +63,22 @@ pub fn main_loop(
|
||||||
|
|
||||||
let mut loop_state = LoopState::default();
|
let mut loop_state = LoopState::default();
|
||||||
let mut world_state = {
|
let mut world_state = {
|
||||||
|
let feature_flags = {
|
||||||
|
let mut ff = FeatureFlags::default();
|
||||||
|
for (flag, value) in config.feature_flags {
|
||||||
|
if ff.set(flag.as_str(), value).is_err() {
|
||||||
|
log::error!("unknown feature flag: {:?}", flag);
|
||||||
|
show_message(
|
||||||
|
req::MessageType::Error,
|
||||||
|
format!("unknown feature flag: {:?}", flag),
|
||||||
|
&connection.sender,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ff
|
||||||
|
};
|
||||||
|
log::info!("feature_flags: {:#?}", feature_flags);
|
||||||
|
|
||||||
// FIXME: support dynamic workspace loading.
|
// FIXME: support dynamic workspace loading.
|
||||||
let workspaces = {
|
let workspaces = {
|
||||||
let mut loaded_workspaces = Vec::new();
|
let mut loaded_workspaces = Vec::new();
|
||||||
|
@ -75,7 +92,11 @@ pub fn main_loop(
|
||||||
Ok(workspace) => loaded_workspaces.push(workspace),
|
Ok(workspace) => loaded_workspaces.push(workspace),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("loading workspace failed: {}", e);
|
log::error!("loading workspace failed: {}", e);
|
||||||
|
if let WorkspaceError::CargoTomlNotFound(_) = e {
|
||||||
|
if !feature_flags.get("notifications.cargo-toml-not-found") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
show_message(
|
show_message(
|
||||||
req::MessageType::Error,
|
req::MessageType::Error,
|
||||||
format!("rust-analyzer failed to load workspace: {}", e),
|
format!("rust-analyzer failed to load workspace: {}", e),
|
||||||
|
@ -136,22 +157,6 @@ pub fn main_loop(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let feature_flags = {
|
|
||||||
let mut ff = FeatureFlags::default();
|
|
||||||
for (flag, value) in config.feature_flags {
|
|
||||||
if ff.set(flag.as_str(), value).is_err() {
|
|
||||||
log::error!("unknown feature flag: {:?}", flag);
|
|
||||||
show_message(
|
|
||||||
req::MessageType::Error,
|
|
||||||
format!("unknown feature flag: {:?}", flag),
|
|
||||||
&connection.sender,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ff
|
|
||||||
};
|
|
||||||
log::info!("feature_flags: {:#?}", feature_flags);
|
|
||||||
|
|
||||||
WorldState::new(
|
WorldState::new(
|
||||||
ws_roots,
|
ws_roots,
|
||||||
workspaces,
|
workspaces,
|
||||||
|
|
|
@ -17,12 +17,11 @@ use ra_db::{CrateGraph, CrateId, Edition, Env, FileId};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use serde_json::from_reader;
|
use serde_json::from_reader;
|
||||||
|
|
||||||
use crate::workspace_error::WorkspaceError;
|
|
||||||
|
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
cargo_workspace::{CargoFeatures, CargoWorkspace, Package, Target, TargetKind},
|
cargo_workspace::{CargoFeatures, CargoWorkspace, Package, Target, TargetKind},
|
||||||
json_project::JsonProject,
|
json_project::JsonProject,
|
||||||
sysroot::Sysroot,
|
sysroot::Sysroot,
|
||||||
|
workspace_error::WorkspaceError,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
@ -118,6 +118,8 @@ host.
|
||||||
"completion.enable-postfix": true,
|
"completion.enable-postfix": true,
|
||||||
// Show notification when workspace is fully loaded
|
// Show notification when workspace is fully loaded
|
||||||
"notifications.workspace-loaded": true,
|
"notifications.workspace-loaded": true,
|
||||||
|
// Show error when no Cargo.toml was found
|
||||||
|
"notifications.cargo-toml-not-found": true,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue