mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-19 18:55:01 +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();
|
||||
defines.insert_scope(&scope);
|
||||
|
||||
defines.insert(
|
||||
EcoString::inline("std"),
|
||||
Ty::Value(InsTy::new(lib.std.read().clone())),
|
||||
);
|
||||
|
||||
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": {
|
||||
"description": "(content, delta: int) => strong"
|
||||
},
|
||||
"sortText": "182",
|
||||
"sortText": "183",
|
||||
"textEdit": {
|
||||
"newText": "strong(${1:})",
|
||||
"range": {
|
||||
|
@ -35,7 +35,7 @@ input_file: crates/tinymist-query/src/fixtures/completion/bracket_strong.typ
|
|||
"labelDetails": {
|
||||
"description": "(content, delta: int) => strong"
|
||||
},
|
||||
"sortText": "183",
|
||||
"sortText": "184",
|
||||
"textEdit": {
|
||||
"newText": "strong[${1:}]",
|
||||
"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": {
|
||||
"description": "type"
|
||||
},
|
||||
"sortText": "185",
|
||||
"sortText": "186",
|
||||
"textEdit": {
|
||||
"newText": "stroke(${1:})",
|
||||
"range": {
|
||||
|
|
|
@ -68,7 +68,7 @@ input_file: crates/tinymist-query/src/fixtures/pkgs/touying-utils-markup-text.ty
|
|||
"labelDetails": {
|
||||
"description": "type"
|
||||
},
|
||||
"sortText": "182",
|
||||
"sortText": "183",
|
||||
"textEdit": {
|
||||
"newText": "str(${1:})",
|
||||
"range": {
|
||||
|
|
|
@ -1228,12 +1228,20 @@ impl ExprWorker<'_> {
|
|||
_ => return (None, None),
|
||||
};
|
||||
|
||||
// ref_expr.val = val.map(|v| Ty::Value(InsTy::new(v.clone())));
|
||||
let val = scope
|
||||
.get(name)
|
||||
.cloned()
|
||||
.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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue