diff options
-rw-r--r-- | crates/ra_ide/src/feature_flags.rs | 1 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 39 | ||||
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 3 | ||||
-rw-r--r-- | docs/user/README.md | 2 |
4 files changed, 26 insertions, 19 deletions
diff --git a/crates/ra_ide/src/feature_flags.rs b/crates/ra_ide/src/feature_flags.rs index de4ae513d..85617640d 100644 --- a/crates/ra_ide/src/feature_flags.rs +++ b/crates/ra_ide/src/feature_flags.rs | |||
@@ -56,6 +56,7 @@ impl Default for FeatureFlags { | |||
56 | ("completion.insertion.add-call-parenthesis", true), | 56 | ("completion.insertion.add-call-parenthesis", true), |
57 | ("completion.enable-postfix", true), | 57 | ("completion.enable-postfix", true), |
58 | ("notifications.workspace-loaded", true), | 58 | ("notifications.workspace-loaded", true), |
59 | ("notifications.cargo-toml-not-found", true), | ||
59 | ]) | 60 | ]) |
60 | } | 61 | } |
61 | } | 62 | } |
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 4336583fe..5ca37981e 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -13,6 +13,7 @@ use lsp_types::{ClientCapabilities, NumberOrString}; | |||
13 | use ra_cargo_watch::{CheckOptions, CheckTask}; | 13 | use ra_cargo_watch::{CheckOptions, CheckTask}; |
14 | use ra_ide::{Canceled, FeatureFlags, FileId, LibraryData, SourceRootId}; | 14 | use ra_ide::{Canceled, FeatureFlags, FileId, LibraryData, SourceRootId}; |
15 | use ra_prof::profile; | 15 | use ra_prof::profile; |
16 | use ra_project_model::WorkspaceError; | ||
16 | use ra_vfs::{VfsTask, Watch}; | 17 | use ra_vfs::{VfsTask, Watch}; |
17 | use relative_path::RelativePathBuf; | 18 | use relative_path::RelativePathBuf; |
18 | use rustc_hash::FxHashSet; | 19 | use rustc_hash::FxHashSet; |
@@ -62,6 +63,22 @@ pub fn main_loop( | |||
62 | 63 | ||
63 | let mut loop_state = LoopState::default(); | 64 | let mut loop_state = LoopState::default(); |
64 | let mut world_state = { | 65 | let mut world_state = { |
66 | let feature_flags = { | ||
67 | let mut ff = FeatureFlags::default(); | ||
68 | for (flag, value) in config.feature_flags { | ||
69 | if ff.set(flag.as_str(), value).is_err() { | ||
70 | log::error!("unknown feature flag: {:?}", flag); | ||
71 | show_message( | ||
72 | req::MessageType::Error, | ||
73 | format!("unknown feature flag: {:?}", flag), | ||
74 | &connection.sender, | ||
75 | ); | ||
76 | } | ||
77 | } | ||
78 | ff | ||
79 | }; | ||
80 | log::info!("feature_flags: {:#?}", feature_flags); | ||
81 | |||
65 | // FIXME: support dynamic workspace loading. | 82 | // FIXME: support dynamic workspace loading. |
66 | let workspaces = { | 83 | let workspaces = { |
67 | let mut loaded_workspaces = Vec::new(); | 84 | let mut loaded_workspaces = Vec::new(); |
@@ -75,7 +92,11 @@ pub fn main_loop( | |||
75 | Ok(workspace) => loaded_workspaces.push(workspace), | 92 | Ok(workspace) => loaded_workspaces.push(workspace), |
76 | Err(e) => { | 93 | Err(e) => { |
77 | log::error!("loading workspace failed: {}", e); | 94 | log::error!("loading workspace failed: {}", e); |
78 | 95 | if let WorkspaceError::CargoTomlNotFound(_) = e { | |
96 | if !feature_flags.get("notifications.cargo-toml-not-found") { | ||
97 | continue; | ||
98 | } | ||
99 | } | ||
79 | show_message( | 100 | show_message( |
80 | req::MessageType::Error, | 101 | req::MessageType::Error, |
81 | format!("rust-analyzer failed to load workspace: {}", e), | 102 | format!("rust-analyzer failed to load workspace: {}", e), |
@@ -136,22 +157,6 @@ pub fn main_loop( | |||
136 | } | 157 | } |
137 | }; | 158 | }; |
138 | 159 | ||
139 | let feature_flags = { | ||
140 | let mut ff = FeatureFlags::default(); | ||
141 | for (flag, value) in config.feature_flags { | ||
142 | if ff.set(flag.as_str(), value).is_err() { | ||
143 | log::error!("unknown feature flag: {:?}", flag); | ||
144 | show_message( | ||
145 | req::MessageType::Error, | ||
146 | format!("unknown feature flag: {:?}", flag), | ||
147 | &connection.sender, | ||
148 | ); | ||
149 | } | ||
150 | } | ||
151 | ff | ||
152 | }; | ||
153 | log::info!("feature_flags: {:#?}", feature_flags); | ||
154 | |||
155 | WorldState::new( | 160 | WorldState::new( |
156 | ws_roots, | 161 | ws_roots, |
157 | workspaces, | 162 | workspaces, |
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index c07c54936..2aa9270c8 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -17,12 +17,11 @@ use ra_db::{CrateGraph, CrateId, Edition, Env, FileId}; | |||
17 | use rustc_hash::FxHashMap; | 17 | use rustc_hash::FxHashMap; |
18 | use serde_json::from_reader; | 18 | use serde_json::from_reader; |
19 | 19 | ||
20 | use crate::workspace_error::WorkspaceError; | ||
21 | |||
22 | pub use crate::{ | 20 | pub use crate::{ |
23 | cargo_workspace::{CargoFeatures, CargoWorkspace, Package, Target, TargetKind}, | 21 | cargo_workspace::{CargoFeatures, CargoWorkspace, Package, Target, TargetKind}, |
24 | json_project::JsonProject, | 22 | json_project::JsonProject, |
25 | sysroot::Sysroot, | 23 | sysroot::Sysroot, |
24 | workspace_error::WorkspaceError, | ||
26 | }; | 25 | }; |
27 | 26 | ||
28 | #[derive(Debug, Clone)] | 27 | #[derive(Debug, Clone)] |
diff --git a/docs/user/README.md b/docs/user/README.md index a4b081dbb..8cf4b68fd 100644 --- a/docs/user/README.md +++ b/docs/user/README.md | |||
@@ -118,6 +118,8 @@ host. | |||
118 | "completion.enable-postfix": true, | 118 | "completion.enable-postfix": true, |
119 | // Show notification when workspace is fully loaded | 119 | // Show notification when workspace is fully loaded |
120 | "notifications.workspace-loaded": true, | 120 | "notifications.workspace-loaded": true, |
121 | // Show error when no Cargo.toml was found | ||
122 | "notifications.cargo-toml-not-found": true, | ||
121 | } | 123 | } |
122 | ``` | 124 | ``` |
123 | 125 | ||