typst_analyzer_analysis/completion/
code.rs

1use tower_lsp::lsp_types::{CompletionItem, CompletionItemKind};
2
3use super::generic::TypCmpItem;
4
5pub fn constructors() -> Vec<CompletionItem> {
6    let mut items = Vec::new();
7    // vec of tuples with the constructor name, the label details and insert text
8    let constructor: Vec<(&str, &str, String)> = vec![
9        (
10            "A line from one point to another.",
11            "line",
12            "#line(length: ${1:100}%, stroke: (paint: rgb(\"#757575\"), thickness: 0.1pt))"
13                .to_owned(),
14        ),
15        (r#"
16# A footnote.
17
18Includes additional remarks and references on the same page with footnotes. A footnote will insert a superscript number that links to the note at the bottom of the page. Notes are numbered sequentially throughout your document and can break across multiple pages.
19
20To customize the appearance of the entry in the footnote listing, see [footnote.entry](https://typst.app/docs/reference/model/footnote/#definitions-entry). The footnote itself is realized as a normal superscript, so you can use a set rule on the [super](https://typst.app/docs/reference/text/super/) function to customize it. You can also apply a show rule to customize only the footnote marker (superscript number) in the running text.
21"#, "footnote", "#footnote[${1:footnote}]".to_owned()),
22    ];
23    for ctx in constructor {
24        let item = TypCmpItem {
25            label: ctx.1.to_owned(),
26            label_details: "code",
27            kind: CompletionItemKind::FUNCTION,
28            documentation: ctx.0,
29            insert_text: ctx.2.to_owned(),
30        };
31        items.push(item);
32    }
33    TypCmpItem::get_cmp(items)
34}