feat: consistently enrich colon after show selectors (#785)

This commit is contained in:
Myriad-Dreamin 2024-11-09 21:26:42 +08:00 committed by GitHub
parent bbee391995
commit 22621a966c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 78 additions and 6 deletions

View file

@ -0,0 +1,2 @@
/// contains: raw, read, raw.with, raw.where, read.with, read.where, replacement, regex selector
#show /* range 0..1 */:

View file

@ -15,7 +15,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show2.typ
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
},
"textEdit": {
"newText": "raw: ",
"newText": "raw: ${1:}",
"range": {
"end": {
"character": 6,
@ -35,7 +35,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/show2.typ
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
},
"textEdit": {
"newText": "raw.where(${1:}): ",
"newText": "raw.where(${1:}): ${2:}",
"range": {
"end": {
"character": 6,

View file

@ -0,0 +1,70 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on / (103..104)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/show3.typ
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 3,
"label": "raw",
"labelDetails": {
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
},
"textEdit": {
"newText": "raw: ${1:}",
"range": {
"end": {
"character": 6,
"line": 1
},
"start": {
"character": 6,
"line": 1
}
}
}
},
{
"kind": 3,
"label": "raw.where",
"labelDetails": {
"description": "(str, align: alignment, block: bool, lang: none | str, syntaxes: [syntax], tab-size: int, theme: [theme]) => raw"
},
"textEdit": {
"newText": "raw.where(${1:}): ${2:}",
"range": {
"end": {
"character": 6,
"line": 1
},
"start": {
"character": 6,
"line": 1
}
}
}
},
{
"kind": 15,
"label": "regex selector",
"textEdit": {
"newText": "regex(\"${1:regex}\"): ${2:}",
"range": {
"end": {
"character": 6,
"line": 1
},
"start": {
"character": 6,
"line": 1
}
}
}
}
]
}
]

View file

@ -634,19 +634,19 @@ fn show_rule_selector_completions(ctx: &mut CompletionContext) {
|value| matches!(value, Value::Func(func) if func.element().is_some()),
);
ctx.enrich("", ": ");
ctx.snippet_completion(
"text selector",
"\"${text}\": ${}",
"\"${text}\"",
"Replace occurrences of specific text.",
);
ctx.snippet_completion(
"regex selector",
"regex(\"${regex}\"): ${}",
"regex(\"${regex}\")",
"Replace matches of a regular expression.",
);
ctx.enrich("", ": ${}");
}
/// Add completions for recipes.