X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=crates%2Frust-analyzer%2Fsrc%2Fconfig.rs;h=5826b6b114c2b455e68eab0d2a08e4b5eacf5f74;hb=a68ce62f6a33d3e5777c1d64c946e0f1d9c7f457;hp=ee6ab698fa4c8ac696b03f234990c94fff7ff61b;hpb=ffc6cdd8714b44a7a50648109fdc8eb42b580c2c;p=rust.git diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index ee6ab698fa4..5826b6b114c 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -58,6 +58,9 @@ struct ConfigData { /// Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`. assist_allowMergingIntoGlobImports: bool = "true", + /// Warm up caches on project load. + cache_warmup: bool = "true", + /// Show function name and docs in parameter hints. callInfo_full: bool = "true", @@ -195,14 +198,16 @@ struct ConfigData { hoverActions_run: bool = "true", /// Whether to show inlay type hints for method chains. - inlayHints_chainingHints: bool = "true", + inlayHints_chainingHints: bool = "true", /// Maximum length for inlay hints. Set to null to have an unlimited length. - inlayHints_maxLength: Option = "25", + inlayHints_maxLength: Option = "25", /// Whether to show function parameter name inlay hints at the call /// site. - inlayHints_parameterHints: bool = "true", + inlayHints_parameterHints: bool = "true", /// Whether to show inlay type hints for variables. - inlayHints_typeHints: bool = "true", + inlayHints_typeHints: bool = "true", + /// Whether to hide inlay hints for constructors. + inlayHints_hideNamedConstructorHints: bool = "false", /// Join lines inserts else between consecutive ifs. joinLines_joinElseIf: bool = "true", @@ -543,6 +548,10 @@ pub fn did_change_watched_files_dynamic_registration(&self) -> bool { ) } + pub fn prefill_caches(&self) -> bool { + self.data.cache_warmup + } + pub fn location_link(&self) -> bool { try_or!(self.caps.text_document.as_ref()?.definition?.link_support?, false) } @@ -768,6 +777,7 @@ pub fn inlay_hints(&self) -> InlayHintsConfig { type_hints: self.data.inlayHints_typeHints, parameter_hints: self.data.inlayHints_parameterHints, chaining_hints: self.data.inlayHints_chainingHints, + hide_named_constructor_hints: self.data.inlayHints_hideNamedConstructorHints, max_length: self.data.inlayHints_maxLength, } } @@ -1289,17 +1299,25 @@ fn generate_package_json_config() { .to_string(); schema.push_str(",\n"); - let mut new_schema = schema.clone(); + // Transform the asciidoc form link to markdown style. + // + // https://link[text] => [text](https://link) let url_matches = schema.match_indices("https://"); - let mut cnt = 0; - for (idx, _) in url_matches { + let mut url_offsets = url_matches.map(|(idx, _)| idx).collect::>(); + url_offsets.reverse(); + for idx in url_offsets { let link = &schema[idx..]; // matching on whitespace to ignore normal links if let Some(link_end) = link.find(|c| c == ' ' || c == '[') { if link.chars().nth(link_end) == Some('[') { - new_schema.insert(idx + cnt, '('); - new_schema.insert(idx + link_end + cnt + 1, ')'); - cnt = cnt + 2; + if let Some(link_text_end) = link.find(']') { + let link_text = link[link_end..(link_text_end + 1)].to_string(); + + schema.replace_range((idx + link_end)..(idx + link_text_end + 1), ""); + schema.insert(idx, '('); + schema.insert(idx + link_end + 1, ')'); + schema.insert_str(idx, &link_text); + } } } } @@ -1314,9 +1332,9 @@ fn generate_package_json_config() { let end = package_json.find(end_marker).unwrap(); let p = remove_ws(&package_json[start..end]); - let s = remove_ws(&new_schema); + let s = remove_ws(&schema); if !p.contains(&s) { - package_json.replace_range(start..end, &new_schema); + package_json.replace_range(start..end, &schema); ensure_file_contents(&package_json_path, &package_json) } }