File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 path = blueprint-compiler
99 url = https://gitlab.gnome.org/jwestman/blueprint-compiler.git
1010[submodule "src/langs/typescript/template/gi-types "]
11- path = src/langs/typescript/ gi-types
11+ path = gi-types
1212 url = https://gitlab.gnome.org/BrainBlasted/gi-typescript-definitions.git
1313 branch = nightly
Submodule
gi-types updated from 0000000 to 396fe14
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import GObject from "gi://GObject";
44import { makeDropdownFlat , settings as global_settings } from "./util.js" ;
55import { setupRustProject } from "./langs/rust/rust.js" ;
66import { setupTypeScriptProject } from "./langs/typescript/typescript.js" ;
7+ import { setupJavascriptProject } from "./langs/javascript/javascript.js" ;
78
89export default function PanelCode ( {
910 builder,
@@ -55,6 +56,12 @@ export default function PanelCode({
5556 stack_code . visible_child_name = panel . language ;
5657 previewer . useInternal ( ) . catch ( console . error ) ;
5758
59+ if ( panel . language . toLowerCase ( ) === "javascript" ) {
60+ setupJavascriptProject ( file , langs . javascript . document ) . catch (
61+ console . error ,
62+ ) ;
63+ }
64+
5865 if ( panel . language . toLowerCase ( ) === "rust" ) {
5966 setupRustProject ( file ) . catch ( console . error ) ;
6067 }
Original file line number Diff line number Diff line change 1- import GLib from "gi://GLib" ;
2-
31import LSPClient from "./lsp/LSPClient.js" ;
42
53const formatting_options = {
@@ -47,14 +45,7 @@ export const languages = [
4745 document : null ,
4846 default_file : "main.js" ,
4947 index : 0 ,
50- language_server : [
51- "biome" ,
52- "lsp-proxy" ,
53- // src/meson.build installs biome.json there
54- GLib . getenv ( "FLATPAK_ID" )
55- ? `--config-path=${ pkg . pkgdatadir } `
56- : `--config-path=src/langs/javascript` ,
57- ] ,
48+ language_server : [ "typescript-language-server" , "--stdio" ] ,
5849 formatting_options : {
5950 ...formatting_options ,
6051 tabSize : 2 ,
Original file line number Diff line number Diff line change 1+ import Gio from "gi://Gio" ;
2+
13import { createLSPClient } from "../../common.js" ;
2- import { getLanguage } from "../../util.js" ;
4+ import { getLanguage , copy } from "../../util.js" ;
35
46export function setup ( { document } ) {
57 const { file, buffer, code_view } = document ;
@@ -30,3 +32,22 @@ export function setup({ document }) {
3032
3133 return lspc ;
3234}
35+
36+ const javascript_template_dir = Gio . File . new_for_path (
37+ pkg . pkgdatadir ,
38+ ) . resolve_relative_path ( "langs/javascript/template" ) ;
39+
40+ export async function setupJavascriptProject ( destination , document ) {
41+ const destination_file = await copy (
42+ "jsconfig.json" ,
43+ javascript_template_dir ,
44+ destination ,
45+ Gio . FileCopyFlags . NONE ,
46+ ) ;
47+
48+ // Notify the language server that the jsconfig file was created
49+ // to initialize diagnostics and type checkings
50+ await document . lspc . notify ( "workspace/didCreateFile" , {
51+ files : [ { uri : destination_file . get_uri ( ) } ] ,
52+ } ) ;
53+ }
Original file line number Diff line number Diff line change 1+ configure_file (
2+ input : ' template/jsconfig.json' ,
3+ output : ' jsconfig.json' ,
4+ install_dir : join_paths (pkgdatadir, ' langs/javascript/template/' ),
5+ configuration : bin_conf,
6+ )
Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "checkJs" : true ,
4+ "module" : " ESNext" ,
5+ "moduleResolution" : " Bundler" ,
6+ // TODO: should probably be fixed to ES2023, or whatever standard is
7+ // currently supported by the latest GJS
8+ "target" : " ESNext" ,
9+ "outDir" : " compiled_javascript" ,
10+ "baseUrl" : " ." ,
11+ "paths" : {
12+ "*" : [" *" , " @pkgdatadir@/langs/typescript/gi-types/*" ]
13+ },
14+ "skipLibCheck" : true
15+ },
16+ "include" : [
17+ " main.js" ,
18+ " @pkgdatadir@/langs/typescript/types/ambient.d.ts" ,
19+ " @pkgdatadir@/langs/typescript/gi-types/gi.d.ts"
20+ ]
21+ }
Original file line number Diff line number Diff line change @@ -11,4 +11,7 @@ install_data(
1111 preserve_path : true ,
1212)
1313
14- install_subdir (' gi-types' , install_dir : join_paths (pkgdatadir, ' langs/typescript' ))
14+ install_subdir (
15+ meson .project_source_root() / ' gi-types' ,
16+ install_dir : join_paths (pkgdatadir, ' langs/typescript' ),
17+ )
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ blueprint_compiler = find_program(
1515
1616meson .add_install_script(' ../build-aux/library.js' , pkgdatadir)
1717
18+ subdir (' langs/javascript' )
1819subdir (' langs/rust/template' )
1920subdir (' langs/typescript' )
2021
Original file line number Diff line number Diff line change @@ -73,7 +73,6 @@ class CodeView extends Gtk.Widget {
7373 }
7474
7575 #onUpdate = ( ) => {
76- this . clearDiagnostics ( ) ;
7776 this . emit ( "changed" ) ;
7877 } ;
7978
You can’t perform that action at this time.
0 commit comments