@@ -78,7 +78,7 @@ const window = new Adw.ApplicationWindow();
78
78
79
79
function createLSPClients ( { root_uri } ) {
80
80
return Object . fromEntries (
81
- [ "javascript" , "blueprint" , "css" , "vala" ] . map ( ( id ) => {
81
+ [ "javascript" , "blueprint" , "css" , "vala" , "rust" ] . map ( ( id ) => {
82
82
const lang = languages . find ( ( language ) => language . id === id ) ;
83
83
const lspc = createLSPClient ( {
84
84
lang,
@@ -397,6 +397,55 @@ async function ci({ filenames, current_dir }) {
397
397
} ) ;
398
398
}
399
399
400
+ const file_rust = demo_dir . get_child ( "code.rs" ) ;
401
+ if ( file_rust . query_exists ( null ) ) {
402
+ print ( ` ${ file_rust . get_path ( ) } ` ) ;
403
+
404
+ const uri = file_rust . get_uri ( ) ;
405
+ const languageId = "rust" ;
406
+ let version = 0 ;
407
+
408
+ const [ contents ] = await file_rust . load_contents_async ( null ) ;
409
+ const text = new TextDecoder ( ) . decode ( contents ) ;
410
+
411
+ await lsp_clients . rust . _notify ( "textDocument/didOpen" , {
412
+ textDocument : {
413
+ uri,
414
+ languageId,
415
+ version : version ++ ,
416
+ text,
417
+ } ,
418
+ } ) ;
419
+
420
+ // FIXME: rust analyzer doesn't publish diagnostics if there are none
421
+ // probably we should switch to pulling diagnostics but unknown if supported
422
+ // https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#textDocument_pullDiagnostics
423
+
424
+ // const diagnostics = await waitForDiagnostics({
425
+ // uri,
426
+ // lspc: lsp_clients.rust,
427
+ // });
428
+ // if (diagnostics.length > 0) {
429
+ // printerr(serializeDiagnostics({ diagnostics }));
430
+ // return false;
431
+ // }
432
+ // print(` ✅ lints`);
433
+
434
+ const checks = await checkFile ( {
435
+ lspc : lsp_clients . rust ,
436
+ file : file_rust ,
437
+ lang : getLanguage ( "rust" ) ,
438
+ uri,
439
+ } ) ;
440
+ if ( ! checks ) return false ;
441
+
442
+ await lsp_clients . rust . _notify ( "textDocument/didClose" , {
443
+ textDocument : {
444
+ uri,
445
+ } ,
446
+ } ) ;
447
+ }
448
+
400
449
await Promise . all (
401
450
Object . entries ( lsp_clients ) . map ( ( [ , lspc ] ) => {
402
451
return lspc . stop ( ) ;
0 commit comments