From 3207f57a78be85b2a1d3cd8f8d723220a9b7aff6 Mon Sep 17 00:00:00 2001 From: Myriad-Dreamin <35292584+Myriad-Dreamin@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:39:59 +0800 Subject: [PATCH] feat: add more postfix snippets (#880) --- .../src/upstream/complete/ext.rs | 62 +++++++++++++++++-- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/crates/tinymist-query/src/upstream/complete/ext.rs b/crates/tinymist-query/src/upstream/complete/ext.rs index 84e7e02f1..5a0da934d 100644 --- a/crates/tinymist-query/src/upstream/complete/ext.rs +++ b/crates/tinymist-query/src/upstream/complete/ext.rs @@ -1712,10 +1712,28 @@ static DEFAULT_POSTFIX_SNIPPET: LazyLock> = LazyLock::new(|| PostfixSnippet { scope: PostfixSnippetScope::Content, mode: eco_vec![InterpretMode::Code, InterpretMode::Markup], - label: "aleft".into(), - label_detail: Some(".align left".into()), - snippet: "align(left, ${node})".into(), - description: "wrap as with align left".into(), + label: eco_format!("text fill"), + label_detail: Some(eco_format!(".text fill")), + snippet: "text(fill: ${}, ${node})".into(), + description: eco_format!("wrap with text fill"), + parsed_snippet: OnceLock::new(), + }, + PostfixSnippet { + scope: PostfixSnippetScope::Content, + mode: eco_vec![InterpretMode::Code, InterpretMode::Markup], + label: eco_format!("text size"), + label_detail: Some(eco_format!(".text size")), + snippet: "text(size: ${}, ${node})".into(), + description: eco_format!("wrap with text size"), + parsed_snippet: OnceLock::new(), + }, + PostfixSnippet { + scope: PostfixSnippetScope::Content, + mode: eco_vec![InterpretMode::Code, InterpretMode::Markup], + label: eco_format!("align"), + label_detail: Some(eco_format!(".align")), + snippet: "align(${}, ${node})".into(), + description: eco_format!("wrap with alignment"), parsed_snippet: OnceLock::new(), }, PostfixSnippet { @@ -1727,6 +1745,33 @@ static DEFAULT_POSTFIX_SNIPPET: LazyLock> = LazyLock::new(|| description: "wrap as if expression".into(), parsed_snippet: OnceLock::new(), }, + PostfixSnippet { + scope: PostfixSnippetScope::Value, + mode: eco_vec![InterpretMode::Code, InterpretMode::Markup], + label: "else".into(), + label_detail: Some(".else".into()), + snippet: "if not ${node} { ${} }".into(), + description: "wrap as if not expression".into(), + parsed_snippet: OnceLock::new(), + }, + PostfixSnippet { + scope: PostfixSnippetScope::Value, + mode: eco_vec![InterpretMode::Code, InterpretMode::Markup], + label: "none".into(), + label_detail: Some(".if none".into()), + snippet: "if ${node} == none { ${} }".into(), + description: "wrap as if expression to check none-ish".into(), + parsed_snippet: OnceLock::new(), + }, + PostfixSnippet { + scope: PostfixSnippetScope::Value, + mode: eco_vec![InterpretMode::Code, InterpretMode::Markup], + label: "notnone".into(), + label_detail: Some(".if not none".into()), + snippet: "if ${node} != none { ${} }".into(), + description: "wrap as if expression to check none-ish".into(), + parsed_snippet: OnceLock::new(), + }, PostfixSnippet { scope: PostfixSnippetScope::Value, mode: eco_vec![InterpretMode::Code, InterpretMode::Markup], @@ -1736,6 +1781,15 @@ static DEFAULT_POSTFIX_SNIPPET: LazyLock> = LazyLock::new(|| description: "wrap as return expression".into(), parsed_snippet: OnceLock::new(), }, + PostfixSnippet { + scope: PostfixSnippetScope::Value, + mode: eco_vec![InterpretMode::Code, InterpretMode::Markup], + label: "tup".into(), + label_detail: Some(".tup".into()), + snippet: "(${node}, ${})".into(), + description: "wrap as tuple (array) expression".into(), + parsed_snippet: OnceLock::new(), + }, PostfixSnippet { scope: PostfixSnippetScope::Value, mode: eco_vec![InterpretMode::Code, InterpretMode::Markup],