[gnome-builder/bilelmoussaoui/rust-analyzer] r-a: Opt-in for the proc-macro expansion feature




commit 2d7bbe6ef55e54a2ba73cca7b62c0c737c2342ad
Author: Bilal Elmoussaoui <belmouss redhat com>
Date:   Thu Feb 3 21:27:30 2022 +0100

    r-a: Opt-in for the proc-macro expansion feature
    
    The proc-macro feature in r-a is still experimental, although without
    it the experience with code that uses proc macros is sub-optimal.
    
    As gtk-rs apps (the most common use case for Builder/Rust) make heavy use of macros
    let us opt-in for that by default

 src/plugins/rust-analyzer/rust-analyzer-service.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/src/plugins/rust-analyzer/rust-analyzer-service.c 
b/src/plugins/rust-analyzer/rust-analyzer-service.c
index 118a8c5f7..7e8175a5b 100644
--- a/src/plugins/rust-analyzer/rust-analyzer-service.c
+++ b/src/plugins/rust-analyzer/rust-analyzer-service.c
@@ -152,6 +152,7 @@ rust_analyzer_service_supervisor_spawned_cb (RustAnalyzerService     *self,
   GInputStream *input;
   const gchar *workdir;
   IdeContext *context;
+  g_autoptr(GVariant) params = NULL;
 
   IDE_ENTRY;
 
@@ -172,6 +173,16 @@ rust_analyzer_service_supervisor_spawned_cb (RustAnalyzerService     *self,
 
   self->client = ide_lsp_client_new (io_stream);
 
+   // Opt-in for the experimental proc-macro feature
+  // See https://rust-analyzer.github.io/manual.html#configuration for details
+  params = JSONRPC_MESSAGE_NEW (
+    "procMacro", "{",
+      "enable", JSONRPC_MESSAGE_PUT_BOOLEAN(TRUE),
+    "}"
+  );
+  ide_lsp_client_set_initialization_options (self->client, params);
+
+
   g_object_set (self->client,
                 "use-markdown-in-diagnostics", TRUE,
                 NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]