Skip to content

Commit 30836dc

Browse files
committed
Auto-commit: Sync changes [2026-03-05]
1 parent a884d95 commit 30836dc

17 files changed

Lines changed: 558 additions & 108 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@hyperpolymath/vordr-vscode",
3+
"version": "0.1.0",
4+
"tasks": {
5+
"build": "deno run -A npm:rescript",
6+
"dev": "deno run -A npm:rescript -w",
7+
"clean": "deno run -A npm:rescript clean",
8+
"package": "deno run -A npm:@vscode/vsce package"
9+
},
10+
"imports": {
11+
"rescript": "npm:rescript@^12.0.0",
12+
"@rescript/core": "npm:@rescript/core@^1.6.1",
13+
"@rescript/runtime/": "npm:/@rescript/runtime@12.2.0/",
14+
"vscode": "npm:vscode@^1.1.37",
15+
"vscode-languageclient/node": "npm:vscode-languageclient@^8.1.0/node"
16+
}
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"cmt_scan":[{"also_scan_build_root":true,"build_root":"lib/bs","scan_dirs":["src"]}],"dirs":["src"],"generated":[],"pkgs":[],"version":2}

container-stack/vordr/editors/vscode/lib/bs/build.ninja

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"version": "12.2.0",
3+
"bsc_path": "/var/mnt/eclipse/hyper-data/cache/deno/npm/registry.npmjs.org/@rescript/linux-x64/12.2.0/bin/bsc.exe",
4+
"bsc_hash": "ca03c46847ff55e2a2115049975f546b655fceff6fc10e34645da2e812314070",
5+
"rescript_config_hash": "c43699e911795bcdb843393ed91ec303fd27fb4584e32692ab7d8604f5ce4426",
6+
"runtime_path": "/var/mnt/eclipse/hyper-data/cache/deno/npm/registry.npmjs.org/@rescript/runtime/12.2.0",
7+
"generated_at": "1772733214403"
8+
}
17.7 KB
Binary file not shown.
5.53 KB
Binary file not shown.
158 Bytes
Binary file not shown.
46.1 KB
Binary file not shown.
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
/**
3+
* Vörðr VSCode Extension
4+
* Fully ported to ReScript v12
5+
*/
6+
7+
module VsCode = {
8+
type disposable = {"dispose": unit => unit}
9+
10+
type extensionContext = {
11+
subscriptions: array<disposable>,
12+
asAbsolutePath: string => string,
13+
extensionPath: string,
14+
}
15+
16+
type textDocument = {
17+
languageId: string,
18+
fileName: string,
19+
}
20+
21+
type textEditor = {document: textDocument}
22+
23+
module Window = {
24+
@module("vscode") @scope("window")
25+
external showInputBox: {"prompt": string, "placeHolder": string} => promise<option<string>> =
26+
"showInputBox"
27+
28+
@module("vscode") @scope("window")
29+
external registerCommand: (string, unit => promise<unit>) => disposable = "registerCommand"
30+
31+
@module("vscode") @scope("window") @val
32+
external activeTextEditor: option<textEditor> = "activeTextEditor"
33+
}
34+
35+
module Workspace = {
36+
type configuration = {get: string => bool}
37+
38+
@module("vscode") @scope("workspace")
39+
external getConfiguration: string => configuration = "getConfiguration"
40+
41+
@module("vscode") @scope("workspace")
42+
external createFileSystemWatcher: string => disposable = "createFileSystemWatcher"
43+
}
44+
}
45+
46+
module Lsp = {
47+
type languageClient
48+
type serverOptions = {
49+
run: {"command": string, "args": array<string>, "transport": int},
50+
debug: {"command": string, "args": array<string>, "transport": int},
51+
}
52+
type clientOptions = {
53+
documentSelector: array<{"scheme": string, "language": string}>,
54+
synchronize: {"fileEvents": VsCode.disposable},
55+
}
56+
57+
@module("vscode-languageclient/node") @new
58+
external makeLanguageClient: (string, string, serverOptions, clientOptions) => languageClient =
59+
"LanguageClient"
60+
61+
@send external start: languageClient => unit = "start"
62+
@send external stop: languageClient => promise<unit> = "stop"
63+
@send
64+
external sendRequest: (languageClient, string, {"command": string, "arguments": array<string>}) => promise<
65+
unit,
66+
> = "sendRequest"
67+
}
68+
69+
module Path = {
70+
@module("path") external join: (string, string) => string = "join"
71+
}
72+
73+
let client: ref<option<Lsp.languageClient>> = ref(None)
74+
75+
let signImage = async () => {
76+
switch (VsCode.Window.activeTextEditor, client.contents) {
77+
| (Some(_editor), Some(c)) => {
78+
let imageName = await VsCode.Window.showInputBox({
79+
"prompt": "Enter container image name",
80+
"placeHolder": "alpine:latest",
81+
})
82+
83+
switch imageName {
84+
| Some(name) =>
85+
await Lsp.sendRequest(
86+
c,
87+
"workspace/executeCommand",
88+
{"command": "vordr.signImage", "arguments": [name]},
89+
)
90+
| None => ()
91+
}
92+
}
93+
| _ => ()
94+
}
95+
}
96+
97+
let verifyImage = async () => {
98+
switch client.contents {
99+
| Some(c) => {
100+
let imageName = await VsCode.Window.showInputBox({
101+
"prompt": "Enter container image name",
102+
"placeHolder": "alpine:latest",
103+
})
104+
105+
switch imageName {
106+
| Some(name) =>
107+
await Lsp.sendRequest(
108+
c,
109+
"workspace/executeCommand",
110+
{"command": "vordr.verifyImage", "arguments": [name]},
111+
)
112+
| None => ()
113+
}
114+
}
115+
| _ => ()
116+
}
117+
}
118+
119+
let activate = (context: VsCode.extensionContext) => {
120+
let config = VsCode.Workspace.getConfiguration("vordr")
121+
122+
if config.get("lsp.enable") {
123+
let lspPath = Path.join(context.extensionPath, "../../src/lsp/Main.res.js")
124+
125+
let serverOptions: Lsp.serverOptions = {
126+
run: {
127+
"command": "deno",
128+
"args": ["run", "--allow-read", "--allow-write", lspPath],
129+
"transport": 1, // TransportKind.stdio
130+
},
131+
debug: {
132+
"command": "deno",
133+
"args": ["run", "--allow-read", "--allow-write", lspPath],
134+
"transport": 1,
135+
},
136+
}
137+
138+
let clientOptions: Lsp.clientOptions = {
139+
documentSelector: [
140+
{"scheme": "file", "language": "ctp"},
141+
{"scheme": "file", "language": "gatekeeper"},
142+
{"scheme": "file", "language": "dockerfile"},
143+
],
144+
synchronize: {
145+
"fileEvents": VsCode.Workspace.createFileSystemWatcher(
146+
"**/.{ctp,gatekeeper.yaml,gatekeeper.yml}",
147+
),
148+
},
149+
}
150+
151+
let c = Lsp.makeLanguageClient("vordrLsp", "Vörðr Language Server", serverOptions, clientOptions)
152+
153+
client := Some(c)
154+
Lsp.start(c)
155+
156+
// Register commands
157+
let _ = Array.push(context.subscriptions, VsCode.Window.registerCommand("vordr.signImage", signImage))
158+
let _ = Array.push(
159+
context.subscriptions,
160+
VsCode.Window.registerCommand("vordr.verifyImage", verifyImage),
161+
)
162+
}
163+
}
164+
165+
let deactivate = () => {
166+
switch client.contents {
167+
| None => Promise.resolve()
168+
| Some(c) => Lsp.stop(c)
169+
}
170+
}
17.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)