diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index f4c154058..b19421c16 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -18,13 +18,13 @@ pub struct Config { | |||
18 | pub client_caps: ClientCapsConfig, | 18 | pub client_caps: ClientCapsConfig, |
19 | 19 | ||
20 | pub with_sysroot: bool, | 20 | pub with_sysroot: bool, |
21 | // TODO: verify that it means what I think it means | ||
21 | pub publish_diagnostics: bool, | 22 | pub publish_diagnostics: bool, |
22 | pub use_client_watching: bool, | ||
23 | // TODO: move to experimental capabilities | 23 | // TODO: move to experimental capabilities |
24 | pub vscode_lldb: bool, | 24 | pub vscode_lldb: bool, |
25 | pub lru_capacity: Option<usize>, | 25 | pub lru_capacity: Option<usize>, |
26 | pub proc_macro_srv: Option<String>, | 26 | pub proc_macro_srv: Option<String>, |
27 | pub exclude_globs: Vec<String>, | 27 | pub files: FilesConfig, |
28 | pub notifications: NotificationsConfig, | 28 | pub notifications: NotificationsConfig, |
29 | 29 | ||
30 | pub cargo: CargoConfig, | 30 | pub cargo: CargoConfig, |
@@ -37,6 +37,18 @@ pub struct Config { | |||
37 | } | 37 | } |
38 | 38 | ||
39 | #[derive(Debug, Clone)] | 39 | #[derive(Debug, Clone)] |
40 | pub struct FilesConfig { | ||
41 | watcher: FilesWatcher, | ||
42 | exclude: Vec<String>, | ||
43 | } | ||
44 | |||
45 | #[derive(Debug, Clone)] | ||
46 | enum FilesWatcher { | ||
47 | Client, | ||
48 | Notify, | ||
49 | } | ||
50 | |||
51 | #[derive(Debug, Clone)] | ||
40 | pub struct NotificationsConfig { | 52 | pub struct NotificationsConfig { |
41 | pub workspace_loaded: bool, | 53 | pub workspace_loaded: bool, |
42 | pub cargo_toml_not_found: bool, | 54 | pub cargo_toml_not_found: bool, |
@@ -67,11 +79,10 @@ impl Default for Config { | |||
67 | 79 | ||
68 | with_sysroot: true, | 80 | with_sysroot: true, |
69 | publish_diagnostics: true, | 81 | publish_diagnostics: true, |
70 | use_client_watching: false, | ||
71 | vscode_lldb: false, | 82 | vscode_lldb: false, |
72 | lru_capacity: None, | 83 | lru_capacity: None, |
73 | proc_macro_srv: None, | 84 | proc_macro_srv: None, |
74 | exclude_globs: Vec::new(), | 85 | files: FilesConfig { watcher: FilesWatcher::Notify, exclude: Vec::new() }, |
75 | notifications: NotificationsConfig { | 86 | notifications: NotificationsConfig { |
76 | workspace_loaded: true, | 87 | workspace_loaded: true, |
77 | cargo_toml_not_found: true, | 88 | cargo_toml_not_found: true, |
@@ -112,39 +123,43 @@ impl Config { | |||
112 | 123 | ||
113 | set(value, "/withSysroot", &mut self.with_sysroot); | 124 | set(value, "/withSysroot", &mut self.with_sysroot); |
114 | set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics); | 125 | set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics); |
115 | set(value, "/useClientWatching", &mut self.use_client_watching); | ||
116 | set(value, "/vscodeLldb", &mut self.vscode_lldb); | 126 | set(value, "/vscodeLldb", &mut self.vscode_lldb); |
117 | set(value, "/lruCapacity", &mut self.lru_capacity); | 127 | set(value, "/lruCapacity", &mut self.lru_capacity); |
118 | set(value, "/excludeGlobs", &mut self.exclude_globs); | 128 | if let Some(watcher) = get::<String>(value, "/files/watcher") { |
119 | set(value, "/featureFlags/notifications.workspace-loaded", &mut self.notifications.workspace_loaded); | 129 | self.files.watcher = match watcher.as_str() { |
120 | set(value, "/featureFlags/notifications.cargo-toml-not-found", &mut self.notifications.cargo_toml_not_found); | 130 | "client" => FilesWatcher::Client, |
121 | 131 | "notify"| _ => FilesWatcher::Notify, | |
122 | set(value, "/cargoFeatures/noDefaultFeatures", &mut self.cargo.no_default_features); | 132 | } |
123 | set(value, "/cargoFeatures/allFeatures", &mut self.cargo.all_features); | 133 | } |
124 | set(value, "/cargoFeatures/features", &mut self.cargo.features); | 134 | set(value, "/notifications/workspaceLoaded", &mut self.notifications.workspace_loaded); |
125 | set(value, "/cargoFeatures/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); | 135 | set(value, "/notifications/cargoTomlNotFound", &mut self.notifications.cargo_toml_not_found); |
136 | |||
137 | set(value, "/cargo/noDefaultFeatures", &mut self.cargo.no_default_features); | ||
138 | set(value, "/cargo/allFeatures", &mut self.cargo.all_features); | ||
139 | set(value, "/cargo/features", &mut self.cargo.features); | ||
140 | set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); | ||
126 | if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { | 141 | if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { |
127 | set(value, "/rustfmtArgs", extra_args); | 142 | set(value, "/rustfmt/extraArgs", extra_args); |
128 | } | 143 | } |
129 | if let Some(false) = get(value, "cargo_watch_enable") { | 144 | if let Some(false) = get(value, "/checkOnSave/enable") { |
130 | self.check = None | 145 | self.check = None |
131 | } else { | 146 | } else { |
132 | if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check | 147 | if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check |
133 | { | 148 | { |
134 | set(value, "/cargoWatchArgs", extra_args); | 149 | set(value, "/checkOnSave/extraArgs", extra_args); |
135 | set(value, "/cargoWatchCommand", command); | 150 | set(value, "/checkOnSave/command", command); |
136 | set(value, "/cargoWatchAllTargets", all_targets); | 151 | set(value, "/checkOnSave/allTargets", all_targets); |
137 | } | 152 | } |
138 | }; | 153 | }; |
139 | 154 | ||
140 | set(value, "/inlayHintsType", &mut self.inlay_hints.type_hints); | 155 | set(value, "/inlayHints/typeHints", &mut self.inlay_hints.type_hints); |
141 | set(value, "/inlayHintsParameter", &mut self.inlay_hints.parameter_hints); | 156 | set(value, "/inlayHints/parameterHints", &mut self.inlay_hints.parameter_hints); |
142 | set(value, "/inlayHintsChaining", &mut self.inlay_hints.chaining_hints); | 157 | set(value, "/inlayHints/chainingHints", &mut self.inlay_hints.chaining_hints); |
143 | set(value, "/inlayHintsMaxLength", &mut self.inlay_hints.max_length); | 158 | set(value, "/inlayHints/maxLength", &mut self.inlay_hints.max_length); |
144 | set(value, "/featureFlags/completion.enable-postfix", &mut self.completion.enable_postfix_completions); | 159 | set(value, "/completion/postfix/enable", &mut self.completion.enable_postfix_completions); |
145 | set(value, "/featureFlags/completion.insertion.add-call-parenthesis", &mut self.completion.add_call_parenthesis); | 160 | set(value, "/completion/addCallParenthesis", &mut self.completion.add_call_parenthesis); |
146 | set(value, "/featureFlags/completion.insertion.add-argument-snippets", &mut self.completion.add_call_argument_snippets); | 161 | set(value, "/completion/addCallArgumentSnippets", &mut self.completion.add_call_argument_snippets); |
147 | set(value, "/featureFlags/call-info.full", &mut self.call_info_full); | 162 | set(value, "/callInfo/full", &mut self.call_info_full); |
148 | 163 | ||
149 | log::info!("Config::update() = {:#?}", self); | 164 | log::info!("Config::update() = {:#?}", self); |
150 | 165 | ||