about summary refs log tree commit diff
path: root/pkgs/development/tools/rust/rust-analyzer
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/tools/rust/rust-analyzer')
-rw-r--r--pkgs/development/tools/rust/rust-analyzer/default.nix6
-rw-r--r--pkgs/development/tools/rust/rust-analyzer/test-neovim-lsp.nix27
2 files changed, 23 insertions, 10 deletions
diff --git a/pkgs/development/tools/rust/rust-analyzer/default.nix b/pkgs/development/tools/rust/rust-analyzer/default.nix
index 941460c35d451..6443cae2f58cd 100644
--- a/pkgs/development/tools/rust/rust-analyzer/default.nix
+++ b/pkgs/development/tools/rust/rust-analyzer/default.nix
@@ -13,14 +13,14 @@
 
 rustPlatform.buildRustPackage rec {
   pname = "rust-analyzer-unwrapped";
-  version = "2024-06-11";
-  cargoSha256 = "sha256-mo3TGaUI1gjJX64Di7+M40CzHkIuFAuXl27yJ9GPkPU=";
+  version = "2024-06-24";
+  cargoSha256 = "sha256-w28YJmL4km+5LBKyo1QlVG376HZ2SyEXPu6SslSvVfg=";
 
   src = fetchFromGitHub {
     owner = "rust-lang";
     repo = "rust-analyzer";
     rev = version;
-    sha256 = "sha256-/N0sZW3xiivMm5klk9zBtzMlO+uaxnUq35kI3bakLx8=";
+    sha256 = "sha256-jzZRTQjXhiwEdzo/SlxP72BUa7g0LVr7MEsaR7A/geg=";
   };
 
   cargoBuildFlags = [ "--bin" "rust-analyzer" "--bin" "rust-analyzer-proc-macro-srv" ];
diff --git a/pkgs/development/tools/rust/rust-analyzer/test-neovim-lsp.nix b/pkgs/development/tools/rust/rust-analyzer/test-neovim-lsp.nix
index 963e134075ed7..49be63a2b99c2 100644
--- a/pkgs/development/tools/rust/rust-analyzer/test-neovim-lsp.nix
+++ b/pkgs/development/tools/rust/rust-analyzer/test-neovim-lsp.nix
@@ -9,20 +9,33 @@ runCommand "test-neovim-rust-analyzer" {
     }
   '';
 
+  # NB. Wait for server done type calculations before sending `hover` request,
+  # otherwise it would return `{unknown}`.
+  # Ref: https://github.com/rust-lang/rust-analyzer/blob/7b11fdeb681c12002861b9804a388efde81c9647/docs/dev/lsp-extensions.md#server-status
   nvimConfig = /* lua */ ''
+    local caps = vim.lsp.protocol.make_client_capabilities()
+    caps["experimental"] = { serverStatusNotification = true }
     vim.lsp.buf_attach_client(vim.api.nvim_get_current_buf(), vim.lsp.start_client({
       cmd = { "rust-analyzer" },
+      capabilities = caps,
       handlers = {
-        ["$/progress"] = function(_, msg, ctx)
-          if msg.token == "rustAnalyzer/Indexing" and msg.value.kind == "end" then
-            vim.cmd("goto 23") -- let mut |var =...
-            vim.lsp.buf.hover()
+        ["experimental/serverStatus"] = function(_, msg, ctx)
+          if msg.health == "ok" then
+            if msg.quiescent then
+              vim.cmd("goto 23") -- let mut |var =...
+              vim.lsp.buf.hover()
+            end
+          else
+            print("error: server status is not ok: ")
+            vim.cmd("q")
           end
         end,
         ["textDocument/hover"] = function(_, msg, ctx)
-          -- Keep newlines.
-          io.write(msg.contents.value)
-          vim.cmd("q")
+          if msg then
+            -- Keep newlines.
+            io.write(msg.contents.value)
+            vim.cmd("q")
+          end
         end,
       },
       on_error = function(code)