From ba1c00223260112badca021e763576742915a1c3 Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Tue, 18 Jun 2024 12:23:55 +0200 Subject: [PATCH 01/22] feat: use the typescript-language-server for TS --- src/common.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/common.js b/src/common.js index 0290a27b7..a3f3679c5 100644 --- a/src/common.js +++ b/src/common.js @@ -128,14 +128,7 @@ export const languages = [ document: null, default_file: "main.ts", index: 4, - language_server: [ - "biome", - "lsp-proxy", - // src/meson.build installs biome.json there - GLib.getenv("FLATPAK_ID") - ? `--config-path=${pkg.pkgdatadir}` - : `--config-path=src/langs/typescript`, - ], + language_server: ["typescript-language-server", "--stdio"], formatting_options: { ...formatting_options, tabSize: 2, From 892a4ce6cc23fe39ce10c94b811e1125e47156fe Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Tue, 18 Jun 2024 14:45:00 +0200 Subject: [PATCH 02/22] feat: add the gi-types submodule --- .gitmodules | 4 ++++ src/langs/typescript/template/gi-types | 1 + 2 files changed, 5 insertions(+) create mode 160000 src/langs/typescript/template/gi-types diff --git a/.gitmodules b/.gitmodules index ffbf57327..0fd4330e6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,7 @@ [submodule "blueprint-compiler"] path = blueprint-compiler url = https://gitlab.gnome.org/jwestman/blueprint-compiler.git +[submodule "src/langs/typescript/template/gi-types"] + path = src/langs/typescript/template/gi-types + url = https://gitlab.gnome.org/BrainBlasted/gi-typescript-definitions.git + branch = nightly diff --git a/src/langs/typescript/template/gi-types b/src/langs/typescript/template/gi-types new file mode 160000 index 000000000..396fe1471 --- /dev/null +++ b/src/langs/typescript/template/gi-types @@ -0,0 +1 @@ +Subproject commit 396fe147142e28a921f0745eff1a562c7a551843 From cb3defdf1be3a26a0237f2290d24f43750c430dd Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Tue, 18 Jun 2024 14:46:22 +0200 Subject: [PATCH 03/22] feat: use the gi-types for GTK types --- src/langs/typescript/template/meson.build | 5 ++++- src/langs/typescript/template/tsconfig.json | 8 +++++--- .../typescript/template/types/gi-module.d.ts | 6 ------ src/langs/typescript/typescript.js | 16 +++++++--------- 4 files changed, 16 insertions(+), 19 deletions(-) delete mode 100644 src/langs/typescript/template/types/gi-module.d.ts diff --git a/src/langs/typescript/template/meson.build b/src/langs/typescript/template/meson.build index 3d4fe6aae..7262b794c 100644 --- a/src/langs/typescript/template/meson.build +++ b/src/langs/typescript/template/meson.build @@ -1,3 +1,6 @@ -install_data(['types/ambient.d.ts', 'types/gi-module.d.ts', 'tsconfig.json'], +install_data(['types/ambient.d.ts', 'tsconfig.json'], install_dir : join_paths(pkgdatadir, 'langs/typescript/template'), preserve_path: true) + +install_subdir('gi-types', + install_dir : join_paths(pkgdatadir, 'langs/typescript/template')) diff --git a/src/langs/typescript/template/tsconfig.json b/src/langs/typescript/template/tsconfig.json index 98dff7bd6..73fd153e3 100644 --- a/src/langs/typescript/template/tsconfig.json +++ b/src/langs/typescript/template/tsconfig.json @@ -6,9 +6,11 @@ // currently supported by the latest GJS "target": "ESNext", "outDir": "compiled_javascript", + "baseUrl": ".", "paths": { - "gi://*": ["./types/gi-module.d.ts"] - } + "*": ["*", "types/*", "gi-types/*"] + }, + "skipLibCheck": true }, - "include": ["main.ts", "types/ambient.d.ts", "types/gi-module.d.ts"] + "include": ["main.ts", "types/ambient.d.ts", "gi-types/gi.d.ts"] } diff --git a/src/langs/typescript/template/types/gi-module.d.ts b/src/langs/typescript/template/types/gi-module.d.ts deleted file mode 100644 index 9ff317d63..000000000 --- a/src/langs/typescript/template/types/gi-module.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// dummy exports for a module imported with "gi://*" -// will be replaced later with actual gi-types - -declare const module: any; - -export default module; diff --git a/src/langs/typescript/typescript.js b/src/langs/typescript/typescript.js index 733cc65f7..bcacd2e5a 100644 --- a/src/langs/typescript/typescript.js +++ b/src/langs/typescript/typescript.js @@ -1,7 +1,7 @@ import Gio from "gi://Gio"; import { createLSPClient } from "../../common.js"; -import { getLanguage, copy } from "../../util.js"; +import { copy, copyDirectory, ensureDir, getLanguage } from "../../util.js"; import { isTypeScriptEnabled } from "../../Extensions/Extensions.js"; export function setup({ document }) { @@ -42,10 +42,10 @@ const typescript_template_dir = Gio.File.new_for_path( export async function setupTypeScriptProject(destination) { const types_destination = destination.get_child("types"); + ensureDir(types_destination); - if (!types_destination.query_exists(null)) { - types_destination.make_directory_with_parents(null); - } + const gi_types_destination = destination.get_child("gi-types"); + ensureDir(gi_types_destination); return Promise.all([ copy( @@ -54,11 +54,9 @@ export async function setupTypeScriptProject(destination) { types_destination, Gio.FileCopyFlags.NONE, ), - copy( - "types/gi-module.d.ts", - typescript_template_dir, - types_destination, - Gio.FileCopyFlags.NONE, + copyDirectory( + typescript_template_dir.get_child("gi-types"), + gi_types_destination, ), copy( "tsconfig.json", From 3c7bf252fb087fe10bcbf184038d263a0ec0130e Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Tue, 18 Jun 2024 15:47:15 +0200 Subject: [PATCH 04/22] feat: add lspc to typescript codeview --- src/langs/typescript/TypeScriptDocument.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/langs/typescript/TypeScriptDocument.js b/src/langs/typescript/TypeScriptDocument.js index e49e026f7..9690ebf1f 100644 --- a/src/langs/typescript/TypeScriptDocument.js +++ b/src/langs/typescript/TypeScriptDocument.js @@ -8,8 +8,8 @@ export class TypeScriptDocument extends Document { super(...args); this.lspc = setup({ document: this }); + this.code_view.lspc = this.lspc; } - async format() { // https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_formatting const text_edits = await this.lspc.request("textDocument/formatting", { From 0f2dbe73a5d286a7930be5b9fd263bbe3a149338 Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Tue, 18 Jun 2024 15:47:55 +0200 Subject: [PATCH 05/22] chore: dont save/restore state with the Typescript LSP --- src/langs/typescript/TypeScriptDocument.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/langs/typescript/TypeScriptDocument.js b/src/langs/typescript/TypeScriptDocument.js index 9690ebf1f..489dee4be 100644 --- a/src/langs/typescript/TypeScriptDocument.js +++ b/src/langs/typescript/TypeScriptDocument.js @@ -25,10 +25,6 @@ export class TypeScriptDocument 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); } } From 7555fd0f47d6b7532166f95a5982c10c69979fa2 Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Tue, 18 Jun 2024 15:48:29 +0200 Subject: [PATCH 06/22] chore: remove the gi-types path from tsconfig --- src/langs/typescript/template/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/langs/typescript/template/tsconfig.json b/src/langs/typescript/template/tsconfig.json index 73fd153e3..9c2e7d0ac 100644 --- a/src/langs/typescript/template/tsconfig.json +++ b/src/langs/typescript/template/tsconfig.json @@ -8,7 +8,7 @@ "outDir": "compiled_javascript", "baseUrl": ".", "paths": { - "*": ["*", "types/*", "gi-types/*"] + "*": ["*", "types/*"] }, "skipLibCheck": true }, From dd2c241fa167c1c0ac369239434099361e844f44 Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Tue, 18 Jun 2024 15:49:52 +0200 Subject: [PATCH 07/22] fix: the LSPClient using a one-based position.character --- src/lsp/LSPClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lsp/LSPClient.js b/src/lsp/LSPClient.js index d19169a65..6545a3cb2 100644 --- a/src/lsp/LSPClient.js +++ b/src/lsp/LSPClient.js @@ -299,7 +299,7 @@ export default class LSPClient { }, position: { line: iter_cursor.get_line(), - character: iter_cursor.get_line_offset() - 1, + character: iter_cursor.get_line_offset(), }, }); From ebd62de9c91a06622963cf4faea5b30c93a33f23 Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Thu, 20 Jun 2024 15:09:12 +0200 Subject: [PATCH 08/22] chore: return name of copied files in `copy`/`copyDirectory` --- src/util.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/util.js b/src/util.js index 7d63134ab..c094e89e1 100644 --- a/src/util.js +++ b/src/util.js @@ -120,16 +120,20 @@ export async function copyDirectory(source, destination) { null, ); + const children = []; + for await (const file_info of enumerator) { const child = enumerator.get_child(file_info); const child_dest = destination.get_child(child.get_basename()); if (file_info.get_file_type() === Gio.FileType.DIRECTORY) { - await copyDirectory(child, child_dest); + const deep_children = await copyDirectory(child, child_dest); + children.push(...deep_children); continue; } try { + children.push(child_dest.get_uri()); await child.copy_async( child_dest, // destination Gio.FileCopyFlags.OVERWRITE, // flags @@ -143,6 +147,8 @@ export async function copyDirectory(source, destination) { } } } + + return children; } export function getNowForFilename() { @@ -191,10 +197,11 @@ export function removeDirectory(file) { export async function copy(filename, source_dir, dest_dir, flags) { const file = source_dir.get_child(filename); + const dest_file = dest_dir.get_child(file.get_basename()); try { await file.copy_async( - dest_dir.get_child(file.get_basename()), // destination + dest_file, // destination flags, // flags GLib.PRIORITY_DEFAULT, // priority null, // cancellable @@ -205,4 +212,6 @@ export async function copy(filename, source_dir, dest_dir, flags) { throw err; } } + + return dest_file.get_uri(); } From 985742e14bc7167fb2e889de1cbca57aced4639b Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Thu, 20 Jun 2024 15:09:52 +0200 Subject: [PATCH 09/22] feat: notify the LSP after setting up typescript project --- src/PanelCode.js | 5 ++++- src/langs/typescript/typescript.js | 12 ++++++++++-- src/window.js | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/PanelCode.js b/src/PanelCode.js index 75d7e553c..5c07fe3a2 100644 --- a/src/PanelCode.js +++ b/src/PanelCode.js @@ -9,6 +9,7 @@ export default function PanelCode({ builder, previewer, session: { settings, file }, + langs, }) { const panel_code = builder.get_object("panel_code"); const button_code = builder.get_object("button_code"); @@ -59,7 +60,9 @@ export default function PanelCode({ } if (panel.language.toLowerCase() === "typescript") { - setupTypeScriptProject(file).catch(console.error); + setupTypeScriptProject(file, langs.typescript.document).catch( + console.error, + ); } } switchLanguage(); diff --git a/src/langs/typescript/typescript.js b/src/langs/typescript/typescript.js index bcacd2e5a..3a06225db 100644 --- a/src/langs/typescript/typescript.js +++ b/src/langs/typescript/typescript.js @@ -40,7 +40,7 @@ const typescript_template_dir = Gio.File.new_for_path( pkg.pkgdatadir, ).resolve_relative_path("langs/typescript/template"); -export async function setupTypeScriptProject(destination) { +export async function setupTypeScriptProject(destination, document) { const types_destination = destination.get_child("types"); ensureDir(types_destination); @@ -64,5 +64,13 @@ export async function setupTypeScriptProject(destination) { destination, Gio.FileCopyFlags.NONE, ), - ]); + ]).then((uris) => { + // notify the language server that are these files were created in the + // workspace + document.lspc._notify("workspace/didCreateFile", { + files: uris.flat().map((uri) => ({ + uri, + })), + }); + }); } diff --git a/src/window.js b/src/window.js index b1462a4e2..773af7eff 100644 --- a/src/window.js +++ b/src/window.js @@ -163,6 +163,7 @@ export default function Window({ application, session }) { builder, previewer, session, + langs, }); previewer.setPanelCode(panel_code); From cde5bfa6e2d0e2588e37167899952dfed8059c9e Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Tue, 2 Jul 2024 18:28:28 +0200 Subject: [PATCH 10/22] chore: add commented types for the global workbench object currently they don't work for some reason, and it's better to declare it as `any` for now --- src/langs/typescript/template/types/ambient.d.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/langs/typescript/template/types/ambient.d.ts b/src/langs/typescript/template/types/ambient.d.ts index 5519bff21..d71b868a9 100644 --- a/src/langs/typescript/template/types/ambient.d.ts +++ b/src/langs/typescript/template/types/ambient.d.ts @@ -1,3 +1,7 @@ +// import Adw from "gi://Adw"; +// import Gtk from "gi://Gtk?version=4.0"; +// import GObject from "gi://GObject"; + // additional type declarations for GJS // additional GJS log utils @@ -31,6 +35,16 @@ declare module "gettext" { ): string; } +// TODO: uncomment correct typings +// declare const workbench: { +// window: Adw.ApplicationWindow; +// application: Adw.Application; +// builder: Gtk.Builder; +// template: string; +// resolve(path: string): string; +// preview(object: Gtk.Widget): void; +// build(params: Record): void; +// }; + // global workbench object -// TODO: use correct typings declare const workbench: any; From 2df4d72d08229675ae93941a83ffc773b1da18ec Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Wed, 3 Jul 2024 13:28:51 +0200 Subject: [PATCH 11/22] chore: move `gi-types` submodules from template folder --- .gitmodules | 2 +- src/langs/typescript/{template => }/gi-types | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/langs/typescript/{template => }/gi-types (100%) diff --git a/.gitmodules b/.gitmodules index 0fd4330e6..0f4a5ee60 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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/template/gi-types + path = src/langs/typescript/gi-types url = https://gitlab.gnome.org/BrainBlasted/gi-typescript-definitions.git branch = nightly diff --git a/src/langs/typescript/template/gi-types b/src/langs/typescript/gi-types similarity index 100% rename from src/langs/typescript/template/gi-types rename to src/langs/typescript/gi-types From e3ac8f5a9e2135dbd8e91d86c1650930cb1dd9be Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Wed, 3 Jul 2024 13:29:48 +0200 Subject: [PATCH 12/22] feat: dont copy over all types --- src/langs/typescript/meson.build | 8 ++++ src/langs/typescript/template/meson.build | 5 +-- src/langs/typescript/template/tsconfig.json | 11 ++++- .../{template => }/types/ambient.d.ts | 0 src/langs/typescript/typescript.js | 41 +++++-------------- src/meson.build | 2 +- 6 files changed, 29 insertions(+), 38 deletions(-) create mode 100644 src/langs/typescript/meson.build rename src/langs/typescript/{template => }/types/ambient.d.ts (100%) diff --git a/src/langs/typescript/meson.build b/src/langs/typescript/meson.build new file mode 100644 index 000000000..543ccc32e --- /dev/null +++ b/src/langs/typescript/meson.build @@ -0,0 +1,8 @@ +install_data(['types/ambient.d.ts'], + install_dir : join_paths(pkgdatadir, 'langs/typescript'), + preserve_path: true) + +install_subdir('gi-types', + install_dir : join_paths(pkgdatadir, 'langs/typescript')) + +subdir('template') diff --git a/src/langs/typescript/template/meson.build b/src/langs/typescript/template/meson.build index 7262b794c..d54294401 100644 --- a/src/langs/typescript/template/meson.build +++ b/src/langs/typescript/template/meson.build @@ -1,6 +1,3 @@ -install_data(['types/ambient.d.ts', 'tsconfig.json'], +install_data(['tsconfig.json'], install_dir : join_paths(pkgdatadir, 'langs/typescript/template'), preserve_path: true) - -install_subdir('gi-types', - install_dir : join_paths(pkgdatadir, 'langs/typescript/template')) diff --git a/src/langs/typescript/template/tsconfig.json b/src/langs/typescript/template/tsconfig.json index 9c2e7d0ac..8998751d8 100644 --- a/src/langs/typescript/template/tsconfig.json +++ b/src/langs/typescript/template/tsconfig.json @@ -8,9 +8,16 @@ "outDir": "compiled_javascript", "baseUrl": ".", "paths": { - "*": ["*", "types/*"] + "*": [ + "*", + "/app/share/re.sonny.Workbench.Devel/langs/typescript/gi-types/*" + ] }, "skipLibCheck": true }, - "include": ["main.ts", "types/ambient.d.ts", "gi-types/gi.d.ts"] + "include": [ + "main.ts", + "/app/share/re.sonny.Workbench.Devel/langs/typescript/types/ambient.d.ts", + "/app/share/re.sonny.Workbench.Devel/langs/typescript/gi-types/gi.d.ts" + ] } diff --git a/src/langs/typescript/template/types/ambient.d.ts b/src/langs/typescript/types/ambient.d.ts similarity index 100% rename from src/langs/typescript/template/types/ambient.d.ts rename to src/langs/typescript/types/ambient.d.ts diff --git a/src/langs/typescript/typescript.js b/src/langs/typescript/typescript.js index 3a06225db..24f5afdf6 100644 --- a/src/langs/typescript/typescript.js +++ b/src/langs/typescript/typescript.js @@ -1,7 +1,7 @@ import Gio from "gi://Gio"; import { createLSPClient } from "../../common.js"; -import { copy, copyDirectory, ensureDir, getLanguage } from "../../util.js"; +import { copy, getLanguage } from "../../util.js"; import { isTypeScriptEnabled } from "../../Extensions/Extensions.js"; export function setup({ document }) { @@ -41,36 +41,15 @@ const typescript_template_dir = Gio.File.new_for_path( ).resolve_relative_path("langs/typescript/template"); export async function setupTypeScriptProject(destination, document) { - const types_destination = destination.get_child("types"); - ensureDir(types_destination); - - const gi_types_destination = destination.get_child("gi-types"); - ensureDir(gi_types_destination); + const destination_uri = await copy( + "tsconfig.json", + typescript_template_dir, + destination, + Gio.FileCopyFlags.NONE, + ); - return Promise.all([ - copy( - "types/ambient.d.ts", - typescript_template_dir, - types_destination, - Gio.FileCopyFlags.NONE, - ), - copyDirectory( - typescript_template_dir.get_child("gi-types"), - gi_types_destination, - ), - copy( - "tsconfig.json", - typescript_template_dir, - destination, - Gio.FileCopyFlags.NONE, - ), - ]).then((uris) => { - // notify the language server that are these files were created in the - // workspace - document.lspc._notify("workspace/didCreateFile", { - files: uris.flat().map((uri) => ({ - uri, - })), - }); + // notify the language server that are the tsconfig file was created + document.lspc._notify("workspace/didCreateFile", { + files: [{ uri: destination_uri }], }); } diff --git a/src/meson.build b/src/meson.build index f6373098c..289f86467 100644 --- a/src/meson.build +++ b/src/meson.build @@ -16,7 +16,7 @@ blueprint_compiler = find_program( meson.add_install_script('../build-aux/library.js', pkgdatadir) subdir('langs/rust/template') -subdir('langs/typescript/template') +subdir('langs/typescript') configure_file( input: 'bin.js', From ac6078e3d1fec0821db4aadcc2bce23e80c30691 Mon Sep 17 00:00:00 2001 From: Angelo Verlain Shema <37999241+vixalien@users.noreply.github.com> Date: Wed, 3 Jul 2024 17:15:35 +0200 Subject: [PATCH 13/22] chore: make notify tsconfig message clearer Co-authored-by: Sonny --- src/langs/typescript/typescript.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/langs/typescript/typescript.js b/src/langs/typescript/typescript.js index 24f5afdf6..43dbb7a13 100644 --- a/src/langs/typescript/typescript.js +++ b/src/langs/typescript/typescript.js @@ -48,7 +48,8 @@ export async function setupTypeScriptProject(destination, document) { Gio.FileCopyFlags.NONE, ); - // notify the language server that are the tsconfig file was created + // Notify the language server that the tsconfig file was created + // to initialized diagnostics and type checkings document.lspc._notify("workspace/didCreateFile", { files: [{ uri: destination_uri }], }); From 81a94e398f123ea7c263724f5bf3bd3a4fa5b3d4 Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Wed, 3 Jul 2024 17:17:30 +0200 Subject: [PATCH 14/22] chore: return `Gio.FIle` from `copy` --- src/langs/typescript/typescript.js | 4 ++-- src/util.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/langs/typescript/typescript.js b/src/langs/typescript/typescript.js index 43dbb7a13..2d8f5b459 100644 --- a/src/langs/typescript/typescript.js +++ b/src/langs/typescript/typescript.js @@ -41,7 +41,7 @@ const typescript_template_dir = Gio.File.new_for_path( ).resolve_relative_path("langs/typescript/template"); export async function setupTypeScriptProject(destination, document) { - const destination_uri = await copy( + const destination_file = await copy( "tsconfig.json", typescript_template_dir, destination, @@ -51,6 +51,6 @@ export async function setupTypeScriptProject(destination, document) { // Notify the language server that the tsconfig file was created // to initialized diagnostics and type checkings document.lspc._notify("workspace/didCreateFile", { - files: [{ uri: destination_uri }], + files: [{ uri: destination_file.get_uri() }], }); } diff --git a/src/util.js b/src/util.js index c094e89e1..c334243a0 100644 --- a/src/util.js +++ b/src/util.js @@ -213,5 +213,5 @@ export async function copy(filename, source_dir, dest_dir, flags) { } } - return dest_file.get_uri(); + return dest_file; } From f8a4f69803a77767002137ecee22cf740b0b0248 Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Wed, 3 Jul 2024 17:23:26 +0200 Subject: [PATCH 15/22] chore: use single meson.build for typescript --- src/langs/typescript/meson.build | 4 +--- src/langs/typescript/template/meson.build | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 src/langs/typescript/template/meson.build diff --git a/src/langs/typescript/meson.build b/src/langs/typescript/meson.build index 543ccc32e..d9537f956 100644 --- a/src/langs/typescript/meson.build +++ b/src/langs/typescript/meson.build @@ -1,8 +1,6 @@ -install_data(['types/ambient.d.ts'], +install_data(['types/ambient.d.ts', 'template/tsconfig.json'], install_dir : join_paths(pkgdatadir, 'langs/typescript'), preserve_path: true) install_subdir('gi-types', install_dir : join_paths(pkgdatadir, 'langs/typescript')) - -subdir('template') diff --git a/src/langs/typescript/template/meson.build b/src/langs/typescript/template/meson.build deleted file mode 100644 index d54294401..000000000 --- a/src/langs/typescript/template/meson.build +++ /dev/null @@ -1,3 +0,0 @@ -install_data(['tsconfig.json'], - install_dir : join_paths(pkgdatadir, 'langs/typescript/template'), - preserve_path: true) From 080c8988506a18328043d5aa618476d7267f7a7d Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Wed, 3 Jul 2024 17:29:06 +0200 Subject: [PATCH 16/22] chore: fix unwanted change --- src/langs/typescript/TypeScriptDocument.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/langs/typescript/TypeScriptDocument.js b/src/langs/typescript/TypeScriptDocument.js index 489dee4be..2b742ac3b 100644 --- a/src/langs/typescript/TypeScriptDocument.js +++ b/src/langs/typescript/TypeScriptDocument.js @@ -10,6 +10,7 @@ export class TypeScriptDocument extends Document { this.lspc = setup({ document: this }); this.code_view.lspc = this.lspc; } + async format() { // https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_formatting const text_edits = await this.lspc.request("textDocument/formatting", { From 9a9ac537aea6f4c558101448ba81e074a44b415a Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Wed, 3 Jul 2024 17:29:17 +0200 Subject: [PATCH 17/22] chore: add TODO when for fixing ambient.d.ts --- src/langs/typescript/types/ambient.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/langs/typescript/types/ambient.d.ts b/src/langs/typescript/types/ambient.d.ts index d71b868a9..e1d519f27 100644 --- a/src/langs/typescript/types/ambient.d.ts +++ b/src/langs/typescript/types/ambient.d.ts @@ -35,7 +35,7 @@ declare module "gettext" { ): string; } -// TODO: uncomment correct typings +// TODO: uncomment correct typings after we switch to `ts-for-gir` // declare const workbench: { // window: Adw.ApplicationWindow; // application: Adw.Application; From 8868eff011dc22292686bf490b16bd21065a92df Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Wed, 3 Jul 2024 17:32:31 +0200 Subject: [PATCH 18/22] chore: use correct notify for tsconfig change --- src/langs/typescript/typescript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/langs/typescript/typescript.js b/src/langs/typescript/typescript.js index 2d8f5b459..ffeb18497 100644 --- a/src/langs/typescript/typescript.js +++ b/src/langs/typescript/typescript.js @@ -50,7 +50,7 @@ export async function setupTypeScriptProject(destination, document) { // Notify the language server that the tsconfig file was created // to initialized diagnostics and type checkings - document.lspc._notify("workspace/didCreateFile", { + await document.lspc.notify("workspace/didCreateFile", { files: [{ uri: destination_file.get_uri() }], }); } From 75531a055205eace6cfff01db5815bc916bcfb30 Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Wed, 3 Jul 2024 17:46:24 +0200 Subject: [PATCH 19/22] chore: revery util.js changes --- src/util.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/util.js b/src/util.js index c334243a0..028cfbdc5 100644 --- a/src/util.js +++ b/src/util.js @@ -120,20 +120,16 @@ export async function copyDirectory(source, destination) { null, ); - const children = []; - for await (const file_info of enumerator) { const child = enumerator.get_child(file_info); const child_dest = destination.get_child(child.get_basename()); if (file_info.get_file_type() === Gio.FileType.DIRECTORY) { - const deep_children = await copyDirectory(child, child_dest); - children.push(...deep_children); + await copyDirectory(child, child_dest); continue; } try { - children.push(child_dest.get_uri()); await child.copy_async( child_dest, // destination Gio.FileCopyFlags.OVERWRITE, // flags @@ -147,8 +143,6 @@ export async function copyDirectory(source, destination) { } } } - - return children; } export function getNowForFilename() { From a06b0ecc641ac48eb7d720e45b05daa1de46391d Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Wed, 3 Jul 2024 17:48:11 +0200 Subject: [PATCH 20/22] chore: remove unnecessary change --- src/langs/typescript/typescript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/langs/typescript/typescript.js b/src/langs/typescript/typescript.js index ffeb18497..2414e148d 100644 --- a/src/langs/typescript/typescript.js +++ b/src/langs/typescript/typescript.js @@ -1,7 +1,7 @@ import Gio from "gi://Gio"; import { createLSPClient } from "../../common.js"; -import { copy, getLanguage } from "../../util.js"; +import { getLanguage, copy } from "../../util.js"; import { isTypeScriptEnabled } from "../../Extensions/Extensions.js"; export function setup({ document }) { From e3553d6b36cc039699fcbc56903e1722ee3b0644 Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Sun, 7 Jul 2024 00:50:43 +0200 Subject: [PATCH 21/22] Use pkgdatadir in tsconfig.json --- src/langs/typescript/biome.json | 19 ------------------- src/langs/typescript/meson.build | 18 +++++++++++++----- src/langs/typescript/template/tsconfig.json | 9 +++------ 3 files changed, 16 insertions(+), 30 deletions(-) delete mode 100644 src/langs/typescript/biome.json diff --git a/src/langs/typescript/biome.json b/src/langs/typescript/biome.json deleted file mode 100644 index 4786af4fb..000000000 --- a/src/langs/typescript/biome.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$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" - } - } - } -} diff --git a/src/langs/typescript/meson.build b/src/langs/typescript/meson.build index d9537f956..103d365b9 100644 --- a/src/langs/typescript/meson.build +++ b/src/langs/typescript/meson.build @@ -1,6 +1,14 @@ -install_data(['types/ambient.d.ts', 'template/tsconfig.json'], - install_dir : join_paths(pkgdatadir, 'langs/typescript'), - preserve_path: true) +configure_file( + input: 'template/tsconfig.json', + output: 'tsconfig.json', + install_dir: join_paths(pkgdatadir, 'langs/typescript/template/'), + configuration: bin_conf, +) -install_subdir('gi-types', - install_dir : join_paths(pkgdatadir, 'langs/typescript')) +install_data( + ['types/ambient.d.ts'], + install_dir: join_paths(pkgdatadir, 'langs/typescript'), + preserve_path: true, +) + +install_subdir('gi-types', install_dir: join_paths(pkgdatadir, 'langs/typescript')) \ No newline at end of file diff --git a/src/langs/typescript/template/tsconfig.json b/src/langs/typescript/template/tsconfig.json index 8998751d8..2fc945907 100644 --- a/src/langs/typescript/template/tsconfig.json +++ b/src/langs/typescript/template/tsconfig.json @@ -8,16 +8,13 @@ "outDir": "compiled_javascript", "baseUrl": ".", "paths": { - "*": [ - "*", - "/app/share/re.sonny.Workbench.Devel/langs/typescript/gi-types/*" - ] + "*": ["*", "@pkgdatadir@/langs/typescript/gi-types/*"] }, "skipLibCheck": true }, "include": [ "main.ts", - "/app/share/re.sonny.Workbench.Devel/langs/typescript/types/ambient.d.ts", - "/app/share/re.sonny.Workbench.Devel/langs/typescript/gi-types/gi.d.ts" + "@pkgdatadir@/langs/typescript/types/ambient.d.ts", + "@pkgdatadir@/langs/typescript/gi-types/gi.d.ts" ] } From 3c4dc9d1070e426e62ddee3eebc60522898ac0bb Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Sun, 7 Jul 2024 01:04:24 +0200 Subject: [PATCH 22/22] fix make ci --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 08c2214d8..0fb6b1d15 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ unit: test: unit lint ./build-aux/fun workbench-cli ci demos/src/Welcome -ci: setup test +ci: setup build test ./build-aux/fun workbench-cli ci demos/src/* # Note that if you have Sdk extensions installed they will be used