@@ -459,128 +459,142 @@ static void initialize_cb(GVariant *return_value, GError *error, gpointer user_d
459
459
460
460
static void perform_initialize (LspServer * server )
461
461
{
462
- GVariant * node ;
463
-
464
462
gchar * locale = lsp_utils_get_locale ();
465
- gchar * project_base_uri = NULL ;
466
463
gchar * project_base = lsp_utils_get_project_base_path ();
464
+ GVariant * workspace_folders = NULL ;
465
+ GVariant * node , * capabilities ;
466
+ gchar * project_base_uri = NULL ;
467
+ GVariantDict dct ;
467
468
468
469
if (project_base )
469
470
project_base_uri = g_filename_to_uri (project_base , NULL , NULL );
470
471
471
- node = JSONRPC_MESSAGE_NEW (
472
- "processId" , JSONRPC_MESSAGE_PUT_INT64 (getpid ()),
473
- "clientInfo" , "{" ,
474
- "name" , JSONRPC_MESSAGE_PUT_STRING ("Geany" ),
475
- "version" , JSONRPC_MESSAGE_PUT_STRING ("0.1" ), //VERSION
472
+ capabilities = JSONRPC_MESSAGE_NEW (
473
+ "window" , "{" ,
474
+ "workDoneProgress" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
476
475
"}" ,
477
- "locale" , JSONRPC_MESSAGE_PUT_STRING (locale ),
478
- "rootPath" , JSONRPC_MESSAGE_PUT_STRING (project_base ),
479
- "workspaceFolders" , "[" , "{" ,
480
- "uri" , JSONRPC_MESSAGE_PUT_STRING (project_base_uri ),
481
- "name" , JSONRPC_MESSAGE_PUT_STRING (project_base ),
482
- "}" , "]" ,
483
- "rootUri" , JSONRPC_MESSAGE_PUT_STRING (project_base_uri ),
484
- "capabilities" , "{" ,
485
- "window" , "{" ,
486
- "workDoneProgress" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
476
+ "textDocument" , "{" ,
477
+ "synchronization" , "{" ,
478
+ "willSave" , JSONRPC_MESSAGE_PUT_BOOLEAN (FALSE),
479
+ "willSaveWaitUntil" , JSONRPC_MESSAGE_PUT_BOOLEAN (FALSE),
480
+ "didSave" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
487
481
"}" ,
488
- "textDocument" , "{" ,
489
- "synchronization" , "{" ,
490
- "willSave" , JSONRPC_MESSAGE_PUT_BOOLEAN (FALSE),
491
- "willSaveWaitUntil" , JSONRPC_MESSAGE_PUT_BOOLEAN (FALSE),
492
- "didSave" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
493
- "}" ,
494
- "completion" , "{" ,
495
- "completionItem" , "{" ,
482
+ "completion" , "{" ,
483
+ "completionItem" , "{" ,
496
484
// "snippetSupport", JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
497
- "documentationFormat" , "[" ,
498
- "plaintext" ,
499
- "]" ,
500
- "}" ,
501
- "completionItemKind" , "{" ,
502
- "valueSet" , "[" ,
503
- LSP_COMPLETION_KINDS ,
504
- "]" ,
505
- "}" ,
506
- "contxtSupport" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
507
- "}" ,
508
- "hover" , "{" ,
509
- "contentFormat" , "[" ,
485
+ "documentationFormat" , "[" ,
510
486
"plaintext" ,
511
487
"]" ,
512
488
"}" ,
513
- "documentSymbol" , "{" ,
514
- "symbolKind" , "{" ,
515
- "valueSet" , "[" ,
516
- LSP_SYMBOL_KINDS ,
517
- "]" ,
518
- "}" ,
519
- "hierarchicalDocumentSymbolSupport" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
520
- "}" ,
521
- "semanticTokens" , "{" ,
522
- "requests" , "{" ,
523
- "range" , JSONRPC_MESSAGE_PUT_BOOLEAN (FALSE),
524
- "full" , "{" ,
525
- "delta" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
526
- "}" ,
527
- "}" ,
528
- "tokenTypes" , "[" ,
529
- // specify all possible token types - gopls returns incorrect offsets without it
530
- // TODO: investigate more and possibly report upstream
531
- "namespace" ,
532
- "type" ,
533
- "class" ,
534
- "enum" ,
535
- "interface" ,
536
- "struct" ,
537
- "typeParameter" ,
538
- "parameter" ,
539
- "variable" ,
540
- "property" ,
541
- "enumMember" ,
542
- "event" ,
543
- "function" ,
544
- "method" ,
545
- "macro" ,
546
- "keyword" ,
547
- "modifier" ,
548
- "comment" ,
549
- "string" ,
550
- "number" ,
551
- "regexp" ,
552
- "operator" ,
553
- "decorator" ,
489
+ "completionItemKind" , "{" ,
490
+ "valueSet" , "[" ,
491
+ LSP_COMPLETION_KINDS ,
554
492
"]" ,
555
- "tokenModifiers" , "[" ,
556
- "]" ,
557
- "formats" , "[" ,
558
- "relative" ,
493
+ "}" ,
494
+ "contxtSupport" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
495
+ "}" ,
496
+ "hover" , "{" ,
497
+ "contentFormat" , "[" ,
498
+ "plaintext" ,
499
+ "]" ,
500
+ "}" ,
501
+ "documentSymbol" , "{" ,
502
+ "symbolKind" , "{" ,
503
+ "valueSet" , "[" ,
504
+ LSP_SYMBOL_KINDS ,
559
505
"]" ,
560
- "overlappingTokenSupport" , JSONRPC_MESSAGE_PUT_BOOLEAN (FALSE),
561
- "multilineTokenSupport" , JSONRPC_MESSAGE_PUT_BOOLEAN (FALSE),
562
- "serverCancelSupport" , JSONRPC_MESSAGE_PUT_BOOLEAN (FALSE),
563
- "augmentsSyntaxTokens" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
564
506
"}" ,
507
+ "hierarchicalDocumentSymbolSupport" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
565
508
"}" ,
566
- "workspace" , "{" ,
567
- "applyEdit" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
568
- "symbol" , "{" ,
569
- "symbolKind" , "{" ,
570
- "valueSet" , "[" ,
571
- LSP_SYMBOL_KINDS ,
572
- "]" ,
509
+ "semanticTokens" , "{" ,
510
+ "requests" , "{" ,
511
+ "range" , JSONRPC_MESSAGE_PUT_BOOLEAN (FALSE),
512
+ "full" , "{" ,
513
+ "delta" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
573
514
"}" ,
574
515
"}" ,
516
+ "tokenTypes" , "[" ,
517
+ // specify all possible token types - gopls returns incorrect offsets without it
518
+ // TODO: investigate more and possibly report upstream
519
+ "namespace" ,
520
+ "type" ,
521
+ "class" ,
522
+ "enum" ,
523
+ "interface" ,
524
+ "struct" ,
525
+ "typeParameter" ,
526
+ "parameter" ,
527
+ "variable" ,
528
+ "property" ,
529
+ "enumMember" ,
530
+ "event" ,
531
+ "function" ,
532
+ "method" ,
533
+ "macro" ,
534
+ "keyword" ,
535
+ "modifier" ,
536
+ "comment" ,
537
+ "string" ,
538
+ "number" ,
539
+ "regexp" ,
540
+ "operator" ,
541
+ "decorator" ,
542
+ "]" ,
543
+ "tokenModifiers" , "[" ,
544
+ "]" ,
545
+ "formats" , "[" ,
546
+ "relative" ,
547
+ "]" ,
548
+ "overlappingTokenSupport" , JSONRPC_MESSAGE_PUT_BOOLEAN (FALSE),
549
+ "multilineTokenSupport" , JSONRPC_MESSAGE_PUT_BOOLEAN (FALSE),
550
+ "serverCancelSupport" , JSONRPC_MESSAGE_PUT_BOOLEAN (FALSE),
551
+ "augmentsSyntaxTokens" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
575
552
"}" ,
576
553
"}" ,
577
- "trace" , JSONRPC_MESSAGE_PUT_STRING ("off" ),
578
- "initializationOptions" , "{" ,
579
- JSONRPC_MESSAGE_PUT_VARIANT (
580
- lsp_utils_parse_json_file (server -> config .initialization_options_file , server -> config .initialization_options )),
554
+ "workspace" , "{" ,
555
+ "applyEdit" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
556
+ "symbol" , "{" ,
557
+ "symbolKind" , "{" ,
558
+ "valueSet" , "[" ,
559
+ LSP_SYMBOL_KINDS ,
560
+ "]" ,
561
+ "}" ,
562
+ "}" ,
563
+ "workspaceFolders" , JSONRPC_MESSAGE_PUT_BOOLEAN (TRUE),
581
564
"}"
582
565
);
583
566
567
+ node = JSONRPC_MESSAGE_NEW (
568
+ "clientInfo" , "{" ,
569
+ "name" , JSONRPC_MESSAGE_PUT_STRING ("Geany LSP Client Plugin" ),
570
+ "version" , JSONRPC_MESSAGE_PUT_STRING (VERSION ),
571
+ "}" ,
572
+ "processId" , JSONRPC_MESSAGE_PUT_INT64 (getpid ()),
573
+ "locale" , JSONRPC_MESSAGE_PUT_STRING (locale ),
574
+ "trace" , JSONRPC_MESSAGE_PUT_STRING ("off" ),
575
+ "rootPath" , JSONRPC_MESSAGE_PUT_STRING (project_base ),
576
+ "rootUri" , JSONRPC_MESSAGE_PUT_STRING (project_base_uri )
577
+ );
578
+
579
+ if (project_base )
580
+ {
581
+ workspace_folders = JSONRPC_MESSAGE_NEW_ARRAY (
582
+ "{" ,
583
+ "uri" , JSONRPC_MESSAGE_PUT_STRING (project_base_uri ),
584
+ "name" , JSONRPC_MESSAGE_PUT_STRING (project_base ),
585
+ "}" );
586
+ }
587
+
588
+ g_variant_dict_init (& dct , node );
589
+
590
+ if (workspace_folders )
591
+ g_variant_dict_insert_value (& dct , "workspaceFolders" , workspace_folders );
592
+ g_variant_dict_insert_value (& dct , "initializationOptions" ,
593
+ lsp_utils_parse_json_file (server -> config .initialization_options_file , server -> config .initialization_options ));
594
+ g_variant_dict_insert_value (& dct , "capabilities" , capabilities );
595
+
596
+ node = g_variant_take_ref (g_variant_dict_end (& dct ));
597
+
584
598
//printf("%s\n\n\n", lsp_utils_json_pretty_print(node));
585
599
586
600
msgwin_status_add (_ ("Sending initialize request to LSP server %s" ), server -> config .cmd );
0 commit comments