summaryrefslogtreecommitdiff
path: root/lsp/rust-analyzer.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lsp/rust-analyzer.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/lsp/rust-analyzer.lua b/lsp/rust-analyzer.lua
index 51f5037..78ed2c5 100644
--- a/lsp/rust-analyzer.lua
+++ b/lsp/rust-analyzer.lua
@@ -1,8 +1,33 @@
+local serverReady = {}
+
return {
cmd = { "rust-analyzer" },
root_markers = { "Cargo.toml" },
filetypes = { "rust" },
+ capabilities = {
+ experimental = {
+ serverStatusNotification = true,
+ },
+ },
+
+ handlers = {
+ ["experimental/serverStatus"] = function(_, result, ctx)
+ -- Try to fix inlay hints not being shown on start of
+ if result.quiescent and not serverReady[ctx.client_id] then
+ for _, bufnr in ipairs(vim.lsp.get_buffers_by_client_id(ctx.client_id)) do
+ -- Re-enable inlay hints so they are refreshed
+ if vim.lsp.inlay_hint.is_enabled() then
+ vim.lsp.inlay_hint.enable(false, { bufnr = bufnr })
+ vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
+ end
+
+ serverReady[ctx.client_id] = true
+ end
+ end
+ end,
+ },
+
settings = {
["rust-analyzer"] = {
checkOnSave = { command = "clippy" },