Skip to content

Commit

Permalink
Merge branch 'main' into atbrat/addfilters
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Jul 14, 2024
2 parents fd1e486 + 6a1dd63 commit b7ee0da
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
path = blueprint-compiler
url = https://gitlab.gnome.org/jwestman/blueprint-compiler.git
[submodule "src/langs/typescript/template/gi-types"]
path = src/langs/typescript/gi-types
path = gi-types
url = https://gitlab.gnome.org/BrainBlasted/gi-typescript-definitions.git
branch = nightly
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ SHELL:=/bin/bash -O globstar

setup:
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install --or-update --user --noninteractive flathub org.gnome.Sdk//46 org.flatpak.Builder org.freedesktop.Sdk.Extension.rust-stable//23.08 org.freedesktop.Sdk.Extension.vala//23.08 org.freedesktop.Sdk.Extension.llvm18//23.08 org.freedesktop.Sdk.Extension.node20//23.08 org.freedesktop.Sdk.Extension.typescript//23.08
flatpak install --or-update --user --noninteractive flathub org.gnome.Sdk//46 org.flatpak.Builder org.freedesktop.Sdk.Extension.rust-stable//23.08 org.freedesktop.Sdk.Extension.vala//23.08 org.freedesktop.Sdk.Extension.llvm18//23.08 org.freedesktop.Sdk.Extension.node18//23.08 org.freedesktop.Sdk.Extension.typescript//23.08
# flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
# flatpak install --or-update --user --noninteractive flathub-beta org.freedesktop.Sdk.Extension.rust-stable//24.08beta org.freedesktop.Sdk.Extension.vala//24.08beta org.freedesktop.Sdk.Extension.llvm18//24.08beta org.freedesktop.Sdk.Extension.node20//24.08beta org.freedesktop.Sdk.Extension.typescript//24.08beta
# flatpak install --or-update --user --noninteractive flathub-beta org.freedesktop.Sdk.Extension.rust-stable//24.08beta org.freedesktop.Sdk.Extension.vala//24.08beta org.freedesktop.Sdk.Extension.llvm18//24.08beta org.freedesktop.Sdk.Extension.node18//24.08beta org.freedesktop.Sdk.Extension.typescript//24.08beta
# flatpak remote-add --user --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
# flatpak install --or-update --user --noninteractive gnome-nightly org.gnome.Sdk//master
git submodule update --init
Expand Down
21 changes: 0 additions & 21 deletions build-aux/modules/biome.json

This file was deleted.

5 changes: 2 additions & 3 deletions build-aux/re.sonny.Workbench.Devel.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"org.freedesktop.Sdk.Extension.vala",
"org.freedesktop.Sdk.Extension.rust-stable",
"org.freedesktop.Sdk.Extension.llvm18",
"org.freedesktop.Sdk.Extension.node20",
"org.freedesktop.Sdk.Extension.node18",
"org.freedesktop.Sdk.Extension.typescript"
],
"build-options": {
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/node20/bin:/usr/lib/sdk/typescript/bin",
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/node18/bin:/usr/lib/sdk/typescript/bin",
"append-ld-library-path": "/usr/lib/sdk/vala/lib"
},
"command": "workbench",
Expand All @@ -39,7 +39,6 @@
],
"modules": [
"modules/blueprint-compiler.json",
"modules/biome.json",
"modules/gst-plugin-gtk4.json",
"modules/vte.json",
"modules/libshumate.json",
Expand Down
5 changes: 2 additions & 3 deletions build-aux/re.sonny.Workbench.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"org.freedesktop.Sdk.Extension.vala",
"org.freedesktop.Sdk.Extension.rust-stable",
"org.freedesktop.Sdk.Extension.llvm18",
"org.freedesktop.Sdk.Extension.node20",
"org.freedesktop.Sdk.Extension.node18",
"org.freedesktop.Sdk.Extension.typescript"
],
"build-options": {
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/node20/bin:/usr/lib/sdk/typescript/bin",
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/node18/bin:/usr/lib/sdk/typescript/bin",
"append-ld-library-path": "/usr/lib/sdk/vala/lib"
},
"command": "workbench",
Expand All @@ -39,7 +39,6 @@
],
"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 @@ -55,7 +55,7 @@
<release version="46.2" date="2024-07-xx">
<description translatable="no">
<ul>
<li>Update Biome to 1.8.3</li>
<li>Replace Biome with TypeScript Language Server</li>
<li>Update gst-plugin-gtk4 to 1.12.7</li>
</ul>
</description>
Expand Down
Submodule gi-types updated from 000000 to 396fe1
8 changes: 4 additions & 4 deletions src/Extensions/Extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ export function Extensions({ window }) {
window.add_action(action_extensions);
}

let rust_enabled = false;
let rust_enabled = null;
export function isRustEnabled() {
rust_enabled ??=
Gio.File.new_for_path("/usr/lib/sdk/rust-stable").query_exists(null) &&
Gio.File.new_for_path(`/usr/lib/sdk/${llvm}`).query_exists(null);
return rust_enabled;
}

let vala_enabled = false;
let vala_enabled = null;
export function isValaEnabled() {
vala_enabled ??=
Gio.File.new_for_path("/usr/lib/sdk/vala").query_exists(null);
return vala_enabled;
}

let typescript_enabled = false;
let typescript_enabled = null;
export function isTypeScriptEnabled() {
typescript_enabled ??=
Gio.File.new_for_path("/usr/lib/sdk/typescript").query_exists(null) &&
Expand All @@ -77,6 +77,6 @@ export function isTypeScriptEnabled() {
}

const llvm = "llvm18";
const node = "node20";
const node = "node18";
const runtime = getFlatpakInfo().get_string("Application", "runtime");
const freedesktop_version = runtime.endsWith("master") ? "24.08beta" : "23.08";
7 changes: 7 additions & 0 deletions src/PanelCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import GObject from "gi://GObject";
import { makeDropdownFlat, settings as global_settings } from "./util.js";
import { setupRustProject } from "./langs/rust/rust.js";
import { setupTypeScriptProject } from "./langs/typescript/typescript.js";
import { setupJavascriptProject } from "./langs/javascript/javascript.js";

export default function PanelCode({
builder,
Expand Down Expand Up @@ -55,6 +56,12 @@ export default function PanelCode({
stack_code.visible_child_name = panel.language;
previewer.useInternal().catch(console.error);

if (panel.language.toLowerCase() === "javascript") {
setupJavascriptProject(file, langs.javascript.document).catch(
console.error,
);
}

if (panel.language.toLowerCase() === "rust") {
setupRustProject(file).catch(console.error);
}
Expand Down
20 changes: 0 additions & 20 deletions src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,7 @@ 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 @@ -90,10 +74,6 @@ 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
11 changes: 1 addition & 10 deletions src/common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import GLib from "gi://GLib";

import LSPClient from "./lsp/LSPClient.js";

const formatting_options = {
Expand Down Expand Up @@ -47,14 +45,7 @@ export const languages = [
document: null,
default_file: "main.js",
index: 0,
language_server: [
"biome",
"lsp-proxy",
// src/meson.build installs biome.json there
GLib.getenv("FLATPAK_ID")
? `--config-path=${pkg.pkgdatadir}`
: `--config-path=src/langs/javascript`,
],
language_server: ["typescript-language-server", "--stdio"],
formatting_options: {
...formatting_options,
tabSize: 2,
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 {
},
});

// Biome doesn't support diff - it just returns one edit
// GTKCssLanguageServer 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: 0 additions & 4 deletions src/langs/javascript/JavaScriptDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ 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: 0 additions & 19 deletions src/langs/javascript/biome.json

This file was deleted.

23 changes: 22 additions & 1 deletion src/langs/javascript/javascript.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Gio from "gi://Gio";

import { createLSPClient } from "../../common.js";
import { getLanguage } from "../../util.js";
import { getLanguage, copy } from "../../util.js";

export function setup({ document }) {
const { file, buffer, code_view } = document;
Expand Down Expand Up @@ -30,3 +32,22 @@ export function setup({ document }) {

return lspc;
}

const javascript_template_dir = Gio.File.new_for_path(
pkg.pkgdatadir,
).resolve_relative_path("langs/javascript/template");

export async function setupJavascriptProject(destination, document) {
const destination_file = await copy(
"jsconfig.json",
javascript_template_dir,
destination,
Gio.FileCopyFlags.NONE,
);

// Notify the language server that the jsconfig file was created
// to initialize diagnostics and type checkings
await document.lspc.notify("workspace/didCreateFile", {
files: [{ uri: destination_file.get_uri() }],
});
}
6 changes: 6 additions & 0 deletions src/langs/javascript/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
configure_file(
input: 'template/jsconfig.json',
output: 'jsconfig.json',
install_dir: join_paths(pkgdatadir, 'langs/javascript/template/'),
configuration: bin_conf,
)
21 changes: 21 additions & 0 deletions src/langs/javascript/template/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"checkJs": true,
"module": "ESNext",
"moduleResolution": "Bundler",
// TODO: should probably be fixed to ES2023, or whatever standard is
// currently supported by the latest GJS
"target": "ESNext",
"outDir": "compiled_javascript",
"baseUrl": ".",
"paths": {
"*": ["*", "@pkgdatadir@/langs/typescript/gi-types/*"]
},
"skipLibCheck": true
},
"include": [
"main.js",
"@pkgdatadir@/langs/typescript/types/ambient.d.ts",
"@pkgdatadir@/langs/typescript/gi-types/gi.d.ts"
]
}
5 changes: 4 additions & 1 deletion src/langs/typescript/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ install_data(
preserve_path: true,
)

install_subdir('gi-types', install_dir: join_paths(pkgdatadir, 'langs/typescript'))
install_subdir(
meson.project_source_root() / 'gi-types',
install_dir: join_paths(pkgdatadir, 'langs/typescript'),
)
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ blueprint_compiler = find_program(

meson.add_install_script('../build-aux/library.js', pkgdatadir)

subdir('langs/javascript')
subdir('langs/rust/template')
subdir('langs/typescript')

Expand Down Expand Up @@ -46,7 +47,6 @@ 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
1 change: 0 additions & 1 deletion src/widgets/CodeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class CodeView extends Gtk.Widget {
}

#onUpdate = () => {
this.clearDiagnostics();
this.emit("changed");
};

Expand Down
2 changes: 1 addition & 1 deletion src/workbench
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export PKG_CONFIG_PATH=/app/lib/pkgconfig/:$PKG_CONFIG_PATH
source /usr/lib/sdk/rust-stable/enable.sh 2> /dev/null
source /usr/lib/sdk/vala/enable.sh 2> /dev/null
source /usr/lib/sdk/llvm18/enable.sh 2> /dev/null
source /usr/lib/sdk/node20/enable.sh 2> /dev/null
source /usr/lib/sdk/node18/enable.sh 2> /dev/null

## enabling the typescript extension
export PATH=$PATH:/usr/lib/sdk/typescript/bin
Expand Down

0 comments on commit b7ee0da

Please sign in to comment.