1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use once_cell::sync::Lazy;
use tower_lsp::lsp_types::{
    CompletionItem, CompletionItemKind, CompletionItemLabelDetails, Documentation,
};

/// Contains all the functions
pub static SNIPPETS: Lazy<Vec<CompletionItem>> = Lazy::new(|| {
    vec![
        CompletionItem {
            label: "CREATE SECRET".to_string(),
            label_details: Some(CompletionItemLabelDetails {
                detail: None,
                description: Some("Generic function".to_string()),
            }),
            insert_text: Some("CREATE SECRET <SECRET_NAME> AS '<SECRET_VALUE>';".to_string()),
            kind: Some(CompletionItemKind::SNIPPET),
            detail: Some("Code snippet to create a Kafka connection.".to_string()),
            deprecated: Some(false),
            documentation: Some(Documentation::String(
                "https://materialize.com/docs/sql/create-secret/".to_string(),
            )),
            ..Default::default()
        },
        CompletionItem {
            label: "CREATE CONNECTION ... TO POSTGRES".to_string(),
            label_details: Some(CompletionItemLabelDetails {
                detail: None,
                description: Some("Generic function".to_string()),
            }),
            insert_text: Some(
                "CREATE CONNECTION <CONNECTION_NAME> TO POSTGRES (
    HOST '<HOST>',
    PORT 5432,
    USER '<USER>',
    PASSWORD SECRET <SECRET_NAME>,
    SSL MODE 'require',
    DATABASE 'postgres'
);"
                .to_string(),
            ),
            kind: Some(CompletionItemKind::SNIPPET),
            detail: Some("Code snippet to create a Postgres connection.".to_string()),
            deprecated: Some(false),
            documentation: Some(Documentation::String(
                "https://materialize.com/docs/sql/create-connection/".to_string(),
            )),
            ..Default::default()
        },
        CompletionItem {
            label: "CREATE CONNECTION ... TO KAFKA".to_string(),
            label_details: Some(CompletionItemLabelDetails {
                detail: None,
                description: Some("Generic function".to_string()),
            }),
            insert_text: Some(
                "CREATE CONNECTION <CONNECTION_NAME> TO KAFKA (
BROKER '<BROKER_URL>',
SSL KEY = SECRET <KEY_SECRET_NAME>,
SSL CERTIFICATE = SECRET <SSL_SECRET_NAME>
);"
                .to_string(),
            ),
            kind: Some(CompletionItemKind::SNIPPET),
            detail: Some("Code snippet to create a Kafka connection.".to_string()),
            deprecated: Some(false),
            documentation: Some(Documentation::String(
                "https://materialize.com/docs/sql/create-connection/".to_string(),
            )),
            ..Default::default()
        },
        CompletionItem {
            label: "CREATE SOURCE ... FROM KAFKA".to_string(),
            label_details: Some(CompletionItemLabelDetails {
                detail: None,
                description: Some("Generic function".to_string()),
            }),
            insert_text: Some(
                "CREATE SOURCE <SOURCE_NAME>
FROM KAFKA CONNECTION <CONNECTION_NAME> (TOPIC '<TOPIC_NAME>')
FORMAT JSON
WITH (SIZE = '3xsmall');"
                    .to_string(),
            ),
            kind: Some(CompletionItemKind::SNIPPET),
            detail: Some("Code snippet to create a Kafka connection.".to_string()),
            deprecated: Some(false),
            documentation: Some(Documentation::String(
                "https://materialize.com/docs/sql/create-source/kafka/".to_string(),
            )),
            ..Default::default()
        },
        CompletionItem {
            label: "CREATE CLUSTER".to_string(),
            label_details: Some(CompletionItemLabelDetails {
                detail: None,
                description: Some("Create cluster".to_string()),
            }),
            insert_text: Some(
                "CREATE CLUSTER <CLUSTER_NAME> SIZE = '<SIZE>', REPLICATION FACTOR = 2;"
                    .to_string(),
            ),
            kind: Some(CompletionItemKind::SNIPPET),
            detail: Some("Code snippet to create a cluster.".to_string()),
            deprecated: Some(false),
            documentation: Some(Documentation::String(
                "https://materialize.com/docs/sql/create-cluster".to_string(),
            )),
            ..Default::default()
        },
    ]
});