|
1 |
| -import { CodedAPI, SnippetLevel } from "code-d-api"; |
| 1 | +import { CodedAPI } from "code-d-api"; |
2 | 2 |
|
3 | 3 | export function builtinPlugins(instance: CodedAPI) {
|
4 |
| - // vibe.d:http snippets |
5 |
| - instance.registerDependencyBasedSnippets(["vibe-d:http"], [ |
6 |
| - { |
7 |
| - levels: [SnippetLevel.method], |
8 |
| - shortcut: "viberouter", |
9 |
| - title: "vibe.d router", |
10 |
| - documentation: "Basic router instance code with GET / path.\n\nReference: https://vibed.org/api/vibe.http.router/URLRouter", |
11 |
| - snippet: 'auto ${1:router} = new URLRouter();\n${1:router}.get("/", &${2:index});' |
12 |
| - }, |
13 |
| - { |
14 |
| - levels: [SnippetLevel.method], |
15 |
| - shortcut: "vibeserver", |
16 |
| - title: "vibe.d HTTP server", |
17 |
| - documentation: "Basic vibe.d HTTP server startup code.\n\nReference: https://vibed.org/api/vibe.http.server/", |
18 |
| - snippet: 'auto ${3:settings} = new HTTPServerSettings();\n' |
19 |
| - + '${3:settings}.port = ${1:3000};\n' |
20 |
| - + '${3:settings}.bindAddresses = ${2:["::1", "127.0.0.1"]};\n' |
21 |
| - + '\n' |
22 |
| - + 'auto ${4:router} = new URLRouter();\n' |
23 |
| - + '${4:router}.get("/", &${5:index});\n' |
24 |
| - + '\n' |
25 |
| - + 'listenHTTP(${3:settings}, ${4:router});\n' |
26 |
| - }, |
27 |
| - { |
28 |
| - levels: [SnippetLevel.method], |
29 |
| - shortcut: "vibeget", |
30 |
| - title: "vibe.d GET request", |
31 |
| - documentation: "Code for a simple low-level async GET request.\n\nReference: https://vibed.org/api/vibe.http.client/requestHTTP", |
32 |
| - snippet: 'requestHTTP(URL("$1"), null, (scope HTTPClientResponse res) {\n\t${2:// TODO: check res.statusCode and read response into parent scope variables.}\n});' |
33 |
| - }, |
34 |
| - { |
35 |
| - levels: [SnippetLevel.method], |
36 |
| - shortcut: "viberequest", |
37 |
| - title: "vibe.d HTTP request (POST/GET/PUT/...)", |
38 |
| - documentation: "Code for a simple low-level async HTTP request.\n\nReference: https://vibed.org/api/vibe.http.client/requestHTTP", |
39 |
| - snippet: 'requestHTTP(URL("$1"), (scope HTTPClientRequest req) {\n\treq.method = HTTPMethod.${2:POST};\n\t${3:// TODO: write request body}\n}, (scope HTTPClientResponse res) {\n\t${4:// TODO: check res.statusCode and read response into parent scope variables.}\n});' |
40 |
| - }, |
41 |
| - { |
42 |
| - levels: [SnippetLevel.method], |
43 |
| - shortcut: "vibegetstring", |
44 |
| - title: "vibe.d GET request into string", |
45 |
| - documentation: "Code for a simple async GET request storing the full response body in a string.\n\nReference: https://vibed.org/api/vibe.http.client/requestHTTP", |
46 |
| - snippet: 'string ${1:text};\nrequestHTTP(URL("$2"), null, (scope HTTPClientResponse res) {\n\t${3:// TODO: check res.statusCode}\n\t${1:text} = res.bodyReader.readAllUTF8();\n});' |
47 |
| - }, |
48 |
| - { |
49 |
| - levels: [SnippetLevel.method], |
50 |
| - shortcut: "vibegetjson", |
51 |
| - title: "vibe.d GET request as json", |
52 |
| - documentation: "Code for a simple async GET request storing the full response body in a string.\n\nReference: https://vibed.org/api/vibe.http.client/requestHTTP", |
53 |
| - snippet: 'Json ${1:json};\nrequestHTTP(URL("$2"), null, (scope HTTPClientResponse res) {\n\t${3:// TODO: check res.statusCode}\n\t${1:json} = res.readJson(); // TODO: possibly want to add .deserializeJson!T\n});' |
54 |
| - }, |
55 |
| - ]); |
| 4 | + // built-in extensions can be put here if they are supposed to come with |
| 5 | + // every code-d install. |
| 6 | + // Special plugins should be installed as separate vscode extensions! |
56 | 7 | }
|
0 commit comments