internal(config): use FxIndexMap for default completion snippets
This commit is contained in:
parent
5dfe55fb49
commit
83c1c4c2bb
4 changed files with 30 additions and 25 deletions
|
|
@ -897,6 +897,7 @@ checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0"
|
|||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.14.5",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1866,6 +1867,7 @@ dependencies = [
|
|||
"ide-completion",
|
||||
"ide-db",
|
||||
"ide-ssr",
|
||||
"indexmap",
|
||||
"intern",
|
||||
"itertools",
|
||||
"load-cargo",
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ expect-test = "1.4.0"
|
|||
hashbrown = { version = "0.14", features = [
|
||||
"inline-more",
|
||||
], default-features = false }
|
||||
indexmap = "2.1.0"
|
||||
indexmap = { version = "2.1.0", features = ["serde"] }
|
||||
itertools = "0.12.0"
|
||||
libc = "0.2.150"
|
||||
libloading = "0.8.0"
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ crossbeam-channel.workspace = true
|
|||
dirs = "5.0.1"
|
||||
dissimilar.workspace = true
|
||||
ide-completion.workspace = true
|
||||
indexmap.workspace = true
|
||||
itertools.workspace = true
|
||||
scip = "0.5.1"
|
||||
lsp-types = { version = "=0.95.0", features = ["proposed"] }
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ use crate::{
|
|||
lsp_ext::{WorkspaceSymbolSearchKind, WorkspaceSymbolSearchScope},
|
||||
};
|
||||
|
||||
type FxIndexMap<K, V> = indexmap::IndexMap<K, V, rustc_hash::FxBuildHasher>;
|
||||
|
||||
mod patch_old_style;
|
||||
|
||||
// Conventions for configuration keys to preserve maximal extendability without breakage:
|
||||
|
|
@ -81,7 +83,7 @@ config_data! {
|
|||
cachePriming_numThreads: NumThreads = NumThreads::Physical,
|
||||
|
||||
/// Custom completion snippets.
|
||||
completion_snippets_custom: FxHashMap<String, SnippetDef> = Config::completion_snippets_default(),
|
||||
completion_snippets_custom: FxIndexMap<String, SnippetDef> = Config::completion_snippets_default(),
|
||||
|
||||
|
||||
/// These paths (file/directories) will be ignored by rust-analyzer. They are
|
||||
|
|
@ -931,7 +933,7 @@ impl Config {
|
|||
patch_old_style::patch_json_for_outdated_configs(&mut json);
|
||||
|
||||
let mut json_errors = vec![];
|
||||
let snips = get_field_json::<FxHashMap<String, SnippetDef>>(
|
||||
let snips = get_field_json::<FxIndexMap<String, SnippetDef>>(
|
||||
&mut json,
|
||||
&mut json_errors,
|
||||
"completion_snippets_custom",
|
||||
|
|
@ -2032,21 +2034,13 @@ impl Config {
|
|||
*self.cfg_setTest(source_root)
|
||||
}
|
||||
|
||||
pub(crate) fn completion_snippets_default() -> FxHashMap<String, SnippetDef> {
|
||||
pub(crate) fn completion_snippets_default() -> FxIndexMap<String, SnippetDef> {
|
||||
serde_json::from_str(
|
||||
r#"{
|
||||
"Arc::new": {
|
||||
"postfix": "arc",
|
||||
"body": "Arc::new(${receiver})",
|
||||
"requires": "std::sync::Arc",
|
||||
"description": "Put the expression into an `Arc`",
|
||||
"scope": "expr"
|
||||
},
|
||||
"Rc::new": {
|
||||
"postfix": "rc",
|
||||
"body": "Rc::new(${receiver})",
|
||||
"requires": "std::rc::Rc",
|
||||
"description": "Put the expression into an `Rc`",
|
||||
"Ok": {
|
||||
"postfix": "ok",
|
||||
"body": "Ok(${receiver})",
|
||||
"description": "Wrap the expression in a `Result::Ok`",
|
||||
"scope": "expr"
|
||||
},
|
||||
"Box::pin": {
|
||||
|
|
@ -2056,10 +2050,17 @@ impl Config {
|
|||
"description": "Put the expression into a pinned `Box`",
|
||||
"scope": "expr"
|
||||
},
|
||||
"Ok": {
|
||||
"postfix": "ok",
|
||||
"body": "Ok(${receiver})",
|
||||
"description": "Wrap the expression in a `Result::Ok`",
|
||||
"Arc::new": {
|
||||
"postfix": "arc",
|
||||
"body": "Arc::new(${receiver})",
|
||||
"requires": "std::sync::Arc",
|
||||
"description": "Put the expression into an `Arc`",
|
||||
"scope": "expr"
|
||||
},
|
||||
"Some": {
|
||||
"postfix": "some",
|
||||
"body": "Some(${receiver})",
|
||||
"description": "Wrap the expression in an `Option::Some`",
|
||||
"scope": "expr"
|
||||
},
|
||||
"Err": {
|
||||
|
|
@ -2068,10 +2069,11 @@ impl Config {
|
|||
"description": "Wrap the expression in a `Result::Err`",
|
||||
"scope": "expr"
|
||||
},
|
||||
"Some": {
|
||||
"postfix": "some",
|
||||
"body": "Some(${receiver})",
|
||||
"description": "Wrap the expression in an `Option::Some`",
|
||||
"Rc::new": {
|
||||
"postfix": "rc",
|
||||
"body": "Rc::new(${receiver})",
|
||||
"requires": "std::rc::Rc",
|
||||
"description": "Put the expression into an `Rc`",
|
||||
"scope": "expr"
|
||||
}
|
||||
}"#,
|
||||
|
|
@ -3210,7 +3212,7 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
|
|||
"FxHashMap<Box<str>, Box<[Box<str>]>>" => set! {
|
||||
"type": "object",
|
||||
},
|
||||
"FxHashMap<String, SnippetDef>" => set! {
|
||||
"FxIndexMap<String, SnippetDef>" => set! {
|
||||
"type": "object",
|
||||
},
|
||||
"FxHashMap<String, String>" => set! {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue