Skip to content

Commit 09500e0

Browse files
committed
request serve-d to use built-in default snippets
1 parent e166127 commit 09500e0

File tree

2 files changed

+5
-53
lines changed

2 files changed

+5
-53
lines changed

src/builtin_plugins.ts

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,7 @@
1-
import { CodedAPI, SnippetLevel } from "code-d-api";
1+
import { CodedAPI } from "code-d-api";
22

33
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!
567
}

src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ function startClient(context: vscode.ExtensionContext) {
191191
"--provide", "http",
192192
"--provide", "implement-snippets",
193193
"--provide", "context-snippets",
194+
"--provide", "default-snippets",
194195
"--provide", "tasks-current",
195196
];
196197

0 commit comments

Comments
 (0)