-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathRegisterCommands.ts
More file actions
40 lines (39 loc) · 1.23 KB
/
RegisterCommands.ts
File metadata and controls
40 lines (39 loc) · 1.23 KB
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
import { Effect, Layer } from "effect";
import { NotebookSerializer } from "../services/NotebookSerializer.ts";
import { VsCode } from "../services/VsCode.ts";
/**
* Registers VS Code commands for the marimo extension.
*/
export const RegisterCommandsLive = Layer.scopedDiscard(
Effect.gen(function* () {
const code = yield* VsCode;
const serializer = yield* NotebookSerializer;
yield* Effect.logInfo("Setting up commands").pipe(
Effect.annotateLogs({ component: "commands" }),
);
yield* code.commands.registerCommand(
"marimo.newMarimoNotebook",
Effect.gen(function* () {
const doc = yield* code.workspace.use((api) =>
api.openNotebookDocument(
serializer.notebookType,
new code.NotebookData([
new code.NotebookCellData(
code.NotebookCellKind.Code,
"",
"python",
),
]),
),
);
yield* code.window.use((api) => api.showNotebookDocument(doc));
yield* Effect.logInfo("Created new marimo notebook").pipe(
Effect.annotateLogs({
component: "commands",
uri: doc.uri.toString(),
}),
);
}),
);
}),
);