Skip to content

Commit

Permalink
Revert "Remove Biome (#973)"
Browse files Browse the repository at this point in the history
This reverts commit 6a1dd63.
  • Loading branch information
sonnyp committed Sep 20, 2024
1 parent 01d0b9c commit b7d84b5
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 2 deletions.
21 changes: 21 additions & 0 deletions build-aux/modules/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "biome",
"buildsystem": "simple",
"build-commands": ["chmod +x biome", "cp biome /app/bin/biome"],
"sources": [
{
"type": "file",
"dest-filename": "biome",
"only-arches": ["aarch64"],
"url": "https://github.com/biomejs/biome/releases/download/cli%2Fv1.8.3/biome-linux-arm64",
"sha256": "d134e89f6f4fc29d32c8101efb074969ac263ebdb0303e07039e3735002c6a2d"
},
{
"type": "file",
"dest-filename": "biome",
"only-arches": ["x86_64"],
"url": "https://github.com/biomejs/biome/releases/download/cli%2Fv1.8.3/biome-linux-x64",
"sha256": "5495f2f69edd94e9f26ed1adb9ed8023d7c143c3cc6f275f90abdded612217e4"
}
]
}
1 change: 1 addition & 0 deletions build-aux/re.sonny.Workbench.Devel.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
],
"modules": [
"modules/blueprint-compiler.json",
"modules/biome.json",
"modules/gst-plugin-gtk4.json",
"modules/vte.json",
"modules/libshumate.json",
Expand Down
1 change: 1 addition & 0 deletions build-aux/re.sonny.Workbench.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
],
"modules": [
"modules/blueprint-compiler.json",
"modules/biome.json",
"modules/gst-plugin-gtk4.json",
"modules/vte.json",
"modules/libshumate.json",
Expand Down
2 changes: 1 addition & 1 deletion data/app.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
</ul>
<p>Dependencies:</p>
<ul>
<li>Replace Biome with TypeScript Language Server</li>
<li>Update Biome to 1.8.3</li>
<li>Update gst-plugin-gtk4 to 1.12.7</li>
<li>Update libshumate to 1.3</li>
<li>Update Blueprint to 0.14.0</li>
Expand Down
20 changes: 20 additions & 0 deletions src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,23 @@ application.connect("open", (_self, files, hint) => {
load().catch(console.error);
});

let proc_biome;

application.connect("startup", () => {
// biome lsp-proxy starts a background server
// it does not get stopped and leaves a process hanging
// so manage it manually instead
// See https://github.com/workbenchdev/Workbench/issues/828
const subprocess_launcher = Gio.SubprocessLauncher.new(
Gio.SubprocessFlags.STDERR_SILENCE,
);
proc_biome = subprocess_launcher.spawnv([
"biome",
"__run_server",
"--config-path",
pkg.pkgdatadir,
]);

Library({
application,
});
Expand All @@ -74,6 +90,10 @@ application.connect("startup", () => {
restoreSessions().catch(console.error);
});

application.connect("shutdown", () => {
proc_biome?.force_exit();
});

application.connect("activate", () => {
if (application.is_remote) {
bootstrap().catch(console.error);
Expand Down
2 changes: 1 addition & 1 deletion src/langs/css/CssDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class CssDocument extends Document {
},
});

// GTKCssLanguageServer doesn't support diff - it just returns one edit
// Biome doesn't support diff - it just returns one edit
// we don't want to loose the cursor position so we use this
const state = this.code_view.saveState();
applyTextEdits(text_edits, this.buffer);
Expand Down
4 changes: 4 additions & 0 deletions src/langs/javascript/JavaScriptDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export class JavaScriptDocument extends Document {
},
});

// Biome doesn't support diff - it just returns one edit
// we don't want to loose the cursor position so we use this
const state = this.code_view.saveState();
applyTextEdits(text_edits, this.buffer);
await this.code_view.restoreState(state);
}
}
19 changes: 19 additions & 0 deletions src/langs/javascript/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://biomejs.dev/schemas/1.3.3/schema.json",
"javascript": {
"globals": ["workbench"]
},
"formatter": {
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"rules": {
"recommended": false,
"correctness": {
"noUndeclaredVariables": "error",
"noUnusedVariables": "warn"
}
}
}
}
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ configure_file(
)

install_data('langs/vala/workbench.vala', install_dir: pkgdatadir)
install_data('langs/javascript/biome.json', install_dir: pkgdatadir)
install_data('project-readme.md', install_dir: pkgdatadir)
subdir('libworkbench')
subdir('Previewer')
Expand Down

0 comments on commit b7d84b5

Please sign in to comment.