Skip to content

Commit 1a6a560

Browse files
authored
Merge branch 'main' into push-klosomrynunw
2 parents a177e13 + 44fab19 commit 1a6a560

19 files changed

+251
-125
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,13 @@ jobs:
3131
- uses: actions/checkout@v4
3232
- uses: astral-sh/setup-uv@v6
3333
- run: uv run ty check
34+
35+
LintTypeScript:
36+
name: Lint (TypeScript)
37+
runs-on: macos-14
38+
steps:
39+
- uses: actions/checkout@v4
40+
- name: Setup Biome
41+
uses: biomejs/setup-biome@v2
42+
with:
43+
working-dir: "extension"

biome.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.2.2/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"ignoreUnknown": false
10+
},
11+
"formatter": {
12+
"enabled": true,
13+
"indentStyle": "space"
14+
},
15+
"linter": {
16+
"enabled": true,
17+
"rules": {
18+
"recommended": true
19+
}
20+
},
21+
"javascript": {
22+
"formatter": {
23+
"quoteStyle": "double"
24+
}
25+
},
26+
"assist": {
27+
"enabled": true,
28+
"actions": {
29+
"source": {
30+
"organizeImports": "on"
31+
}
32+
}
33+
}
34+
}

extension/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@
9595
"scripts": {
9696
"build": "turbo run build:renderer build:extension",
9797
"build:extension": "esbuild --format=cjs --platform=node --minify --external:vscode --bundle --sourcemap src/extension.ts --outdir=dist",
98-
"build:renderer": "vite build"
98+
"build:renderer": "vite build",
99+
"fix": "biome check --write"
99100
},
100101
"devDependencies": {
102+
"@biomejs/biome": "^2.2.2",
101103
"@marimo-team/frontend": "link:../../marimo/frontend/",
102104
"@marimo-team/openapi": "link:../../marimo/packages/openapi/",
103105
"@tailwindcss/vite": "^4.1.11",

extension/pnpm-lock.yaml

Lines changed: 91 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/scripts/vite-plugin-virtual-stylesheet.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* @returns {import("vite").Plugin}
77
*/
8-
export default function() {
8+
export default function () {
99
const needle = "__INLINE_STYLES_PLACEHOLDER__";
1010
return {
1111
name: "virtual-stylesheet",

extension/src/assert.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ export class AssertionError extends Error {
2727
* @param msg - The error message to throw if the assertion fails.
2828
* @throws {Error} If `expression` is falsy.
2929
*/
30-
export function assert(
31-
expression: unknown,
32-
msg?: string,
33-
): asserts expression {
30+
export function assert(expression: unknown, msg?: string): asserts expression {
3431
if (!expression) {
3532
if (process.env.NODE_ENV === "development") {
36-
// Triggers a breakpoint in development; stripped out in production builds.
33+
// biome-ignore lint/suspicious/noDebugger: Triggers a breakpoint in development; stripped out in production builds.
3734
debugger;
3835
}
36+
3937
throw new AssertionError(msg);
4038
}
4139
}

extension/src/commands.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1-
import * as lsp from "vscode-languageclient";
21
import * as vscode from "vscode";
2+
import type * as lsp from "vscode-languageclient";
33

44
import { AssertionError } from "./assert.ts";
55
import { Logger } from "./logging.ts";
66
import type { RequestMap } from "./types.ts";
77

8-
export function registerCommand(
9-
command: string,
10-
callback: () => unknown,
11-
) {
8+
export function registerCommand(command: string, callback: () => unknown) {
129
return vscode.commands.registerCommand(command, () => {
1310
Logger.info("Command.Execute", `Running command: ${command}`);
14-
return Promise
15-
.resolve(callback())
16-
.catch((error: unknown) => {
17-
let message: string;
18-
if (error instanceof AssertionError) {
19-
message = error.message;
20-
} else {
21-
message = `Unknown error: ${JSON.stringify(error)}`;
22-
}
23-
Logger.error("Command.Execute", `Command failed: ${command}`, error);
24-
vscode.window.showWarningMessage(message);
25-
});
11+
return Promise.resolve(callback()).catch((error: unknown) => {
12+
let message: string;
13+
if (error instanceof AssertionError) {
14+
message = error.message;
15+
} else {
16+
message = `Unknown error: ${JSON.stringify(error)}`;
17+
}
18+
Logger.error("Command.Execute", `Command failed: ${command}`, error);
19+
vscode.window.showWarningMessage(message);
20+
});
2621
});
2722
}
2823

@@ -42,10 +37,15 @@ export function executeCommand<K extends keyof RequestMap>(
4237
options.params,
4338
);
4439

45-
return client.sendRequest<unknown>("workspace/executeCommand", {
46-
command: options.command,
47-
arguments: [options.params],
48-
}, options.token)
40+
return client
41+
.sendRequest<unknown>(
42+
"workspace/executeCommand",
43+
{
44+
command: options.command,
45+
arguments: [options.params],
46+
},
47+
options.token,
48+
)
4949
.then((result) => {
5050
Logger.debug("Command.LSP", `Command completed: ${options.command}`, {
5151
duration: Date.now() - startTime,

extension/src/extension.ts

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import * as vscode from "vscode";
22
import * as lsp from "vscode-languageclient/node";
33

44
import { debugAdapter } from "./debugAdapter.ts";
5+
6+
import * as cmds from "./commands.ts";
7+
58
import { kernelManager } from "./kernelManager.ts";
69
import { languageClient } from "./languageClient.ts";
7-
import { notebookSerializer } from "./notebookSerializer.ts";
810

911
import { Logger } from "./logging.ts";
10-
import * as cmds from "./commands.ts";
12+
import { notebookSerializer } from "./notebookSerializer.ts";
1113
import { notebookType } from "./types.ts";
1214

1315
export async function activate(context: vscode.ExtensionContext) {
@@ -42,28 +44,31 @@ export async function activate(context: vscode.ExtensionContext) {
4244
}),
4345
);
4446

45-
await client.start().then(() => {
46-
Logger.info("Extension.Lifecycle", "LSP client started successfully");
47-
// Forward logs from the LSP server
48-
client.onNotification(
49-
"window/logMessage",
50-
({ type, message }: lsp.LogMessageParams) => {
51-
const mapping = {
52-
[lsp.MessageType.Error]: "error",
53-
[lsp.MessageType.Warning]: "warn",
54-
[lsp.MessageType.Info]: "info",
55-
[lsp.MessageType.Log]: "info",
56-
[lsp.MessageType.Debug]: "debug",
57-
} as const;
58-
Logger[mapping[type]]("LSP.Server", message);
59-
},
60-
);
61-
}).catch((error) => {
62-
Logger.error("Extension.Lifecycle", "Failed to start LSP client", error);
63-
vscode.window.showErrorMessage(
64-
`Marimo language server failed to start ${JSON.stringify(error.message)}`,
65-
);
66-
});
47+
await client
48+
.start()
49+
.then(() => {
50+
Logger.info("Extension.Lifecycle", "LSP client started successfully");
51+
// Forward logs from the LSP server
52+
client.onNotification(
53+
"window/logMessage",
54+
({ type, message }: lsp.LogMessageParams) => {
55+
const mapping = {
56+
[lsp.MessageType.Error]: "error",
57+
[lsp.MessageType.Warning]: "warn",
58+
[lsp.MessageType.Info]: "info",
59+
[lsp.MessageType.Log]: "info",
60+
[lsp.MessageType.Debug]: "debug",
61+
} as const;
62+
Logger[mapping[type]]("LSP.Server", message);
63+
},
64+
);
65+
})
66+
.catch((error) => {
67+
Logger.error("Extension.Lifecycle", "Failed to start LSP client", error);
68+
vscode.window.showErrorMessage(
69+
`Marimo language server failed to start ${JSON.stringify(error.message)}`,
70+
);
71+
});
6772
Logger.info("Extension.Lifecycle", "Activation complete");
6873
}
6974

extension/src/kernelManager.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as vscode from "vscode";
2-
import * as lsp from "vscode-languageclient";
3-
4-
import { Logger } from "./logging.ts";
2+
import type * as lsp from "vscode-languageclient";
3+
import { assert } from "./assert.ts";
54
import * as cmds from "./commands.ts";
5+
import { Logger } from "./logging.ts";
66
import * as ops from "./operations.ts";
7-
import { assert } from "./assert.ts";
87
import { notebookType } from "./types.ts";
98

109
export function kernelManager(

extension/src/languageClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import * as lsp from "vscode-languageclient/node";
22

33
import { channel, Logger } from "./logging.ts";
44

5-
export function languageClient(
6-
opts: { signal: AbortSignal },
7-
): lsp.BaseLanguageClient {
5+
export function languageClient(opts: {
6+
signal: AbortSignal;
7+
}): lsp.BaseLanguageClient {
88
const client = new lsp.LanguageClient(
99
"marimo-lsp",
1010
"Marimo Language Server",

0 commit comments

Comments
 (0)