Merge pull request #322183 from oxalica/pkg/rust-analyzer

rust-analyzer-unwrapped: 2024-06-11 -> 2024-06-24 and fix tests
This commit is contained in:
Nick Cao 2024-06-27 20:25:04 -04:00 committed by GitHub
commit 5f58944067
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 10 deletions

View File

@ -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" ];

View File

@ -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)