mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-02 17:32:16 +00:00
feat: complete std
which isn't in any builtin scopes (#1483)
* feat: complete `std` which isn't in any builtin scopes * test: update snapshot * test: update snapshot * test: update snapshot
This commit is contained in:
parent
be9c0478f6
commit
e8507fea96
10 changed files with 71 additions and 8 deletions
|
@ -98,6 +98,11 @@ impl CompletionPair<'_, '_, '_> {
|
||||||
.clone();
|
.clone();
|
||||||
defines.insert_scope(&scope);
|
defines.insert_scope(&scope);
|
||||||
|
|
||||||
|
defines.insert(
|
||||||
|
EcoString::inline("std"),
|
||||||
|
Ty::Value(InsTy::new(lib.std.read().clone())),
|
||||||
|
);
|
||||||
|
|
||||||
Some(defines)
|
Some(defines)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
/// contains: std
|
||||||
|
#show raw: s/* range 0..1 */
|
|
@ -0,0 +1,2 @@
|
||||||
|
/// contains: std
|
||||||
|
#s/* range 0..1 */
|
|
@ -14,7 +14,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/bracket_strong.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content, delta: int) => strong"
|
"description": "(content, delta: int) => strong"
|
||||||
},
|
},
|
||||||
"sortText": "182",
|
"sortText": "183",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "strong(${1:})",
|
"newText": "strong(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
@ -35,7 +35,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/bracket_strong.typ
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "(content, delta: int) => strong"
|
"description": "(content, delta: int) => strong"
|
||||||
},
|
},
|
||||||
"sortText": "183",
|
"sortText": "184",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "strong[${1:}]",
|
"newText": "strong[${1:}]",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
source: crates/tinymist-query/src/completion.rs
|
||||||
|
description: Completion on / (30..31)
|
||||||
|
expression: "JsonRepr::new_pure(results)"
|
||||||
|
input_file: crates/tinymist-query/src/fixtures/completion/module_show.typ
|
||||||
|
---
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"isIncomplete": false,
|
||||||
|
"items": []
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1,34 @@
|
||||||
|
---
|
||||||
|
source: crates/tinymist-query/src/completion.rs
|
||||||
|
description: Completion on / (20..21)
|
||||||
|
expression: "JsonRepr::new_pure(results)"
|
||||||
|
input_file: crates/tinymist-query/src/fixtures/completion/module_std.typ
|
||||||
|
---
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"isIncomplete": false,
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"kind": 9,
|
||||||
|
"label": "std",
|
||||||
|
"labelDetails": {
|
||||||
|
"description": "module(\"global\")"
|
||||||
|
},
|
||||||
|
"sortText": "177",
|
||||||
|
"textEdit": {
|
||||||
|
"newText": "std",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 2,
|
||||||
|
"line": 1
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 1,
|
||||||
|
"line": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
|
@ -35,7 +35,7 @@ input_file: crates/tinymist-query/src/fixtures/pkgs/touying-utils-cover-with-rec
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "type"
|
"description": "type"
|
||||||
},
|
},
|
||||||
"sortText": "185",
|
"sortText": "186",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "stroke(${1:})",
|
"newText": "stroke(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
@ -68,7 +68,7 @@ input_file: crates/tinymist-query/src/fixtures/pkgs/touying-utils-markup-text.ty
|
||||||
"labelDetails": {
|
"labelDetails": {
|
||||||
"description": "type"
|
"description": "type"
|
||||||
},
|
},
|
||||||
"sortText": "182",
|
"sortText": "183",
|
||||||
"textEdit": {
|
"textEdit": {
|
||||||
"newText": "str(${1:})",
|
"newText": "str(${1:})",
|
||||||
"range": {
|
"range": {
|
||||||
|
|
|
@ -1228,12 +1228,20 @@ impl ExprWorker<'_> {
|
||||||
_ => return (None, None),
|
_ => return (None, None),
|
||||||
};
|
};
|
||||||
|
|
||||||
// ref_expr.val = val.map(|v| Ty::Value(InsTy::new(v.clone())));
|
|
||||||
let val = scope
|
let val = scope
|
||||||
.get(name)
|
.get(name)
|
||||||
.cloned()
|
.cloned()
|
||||||
.map(|val| Ty::Value(InsTy::new(val.read().clone())));
|
.map(|val| Ty::Value(InsTy::new(val.read().clone())));
|
||||||
(None, val)
|
if let Some(val) = val {
|
||||||
|
return (None, Some(val));
|
||||||
|
}
|
||||||
|
|
||||||
|
if name.as_ref() == "std" {
|
||||||
|
let val = Ty::Value(InsTy::new(self.ctx.world.library.std.read().clone()));
|
||||||
|
return (None, Some(val));
|
||||||
|
}
|
||||||
|
|
||||||
|
(None, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_expr_and_val(&mut self, src: ConcolicExpr) -> Option<Expr> {
|
fn fold_expr_and_val(&mut self, src: ConcolicExpr) -> Option<Expr> {
|
||||||
|
|
|
@ -374,7 +374,7 @@ fn e2e() {
|
||||||
});
|
});
|
||||||
|
|
||||||
let hash = replay_log(&tinymist_binary, &root.join("neovim"));
|
let hash = replay_log(&tinymist_binary, &root.join("neovim"));
|
||||||
insta::assert_snapshot!(hash, @"siphash128_13:2655017d733b6c6c753d92c5d5bbc65d");
|
insta::assert_snapshot!(hash, @"siphash128_13:ce179598883927533514674aa7930054");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -385,7 +385,7 @@ fn e2e() {
|
||||||
});
|
});
|
||||||
|
|
||||||
let hash = replay_log(&tinymist_binary, &root.join("vscode"));
|
let hash = replay_log(&tinymist_binary, &root.join("vscode"));
|
||||||
insta::assert_snapshot!(hash, @"siphash128_13:934ee53fdb376bbeba357953499f7a5f");
|
insta::assert_snapshot!(hash, @"siphash128_13:60813619e4478214e898a3d277ac031b");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue