diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ac5ca86..a660020e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- LSP: Add more information to rust-analyzer unhealthy notifications + ## [5.6.0] - 2024-09-18 ### Added diff --git a/lua/rustaceanvim/config/internal.lua b/lua/rustaceanvim/config/internal.lua index 198e3bef..b7797af5 100644 --- a/lua/rustaceanvim/config/internal.lua +++ b/lua/rustaceanvim/config/internal.lua @@ -10,6 +10,7 @@ local RustaceanConfig ---@class rustaceanvim.internal.RAInitializedStatus : rustaceanvim.RAInitializedStatus ---@field health rustaceanvim.lsp_server_health_status ---@field quiescent boolean inactive? +---@field message string | nil --- ---@param dap_adapter rustaceanvim.dap.executable.Config | rustaceanvim.dap.server.Config | rustaceanvim.disable ---@return boolean diff --git a/lua/rustaceanvim/server_status.lua b/lua/rustaceanvim/server_status.lua index 14a8ef28..46d35314 100644 --- a/lua/rustaceanvim/server_status.lua +++ b/lua/rustaceanvim/server_status.lua @@ -7,11 +7,21 @@ local _ran_once = {} ---@param result rustaceanvim.internal.RAInitializedStatus function M.handler(_, result, ctx, _) - if result and result.health and result.health ~= 'ok' then - vim.notify_once("rust-analyzer health is not OK. Run 'RustLsp logFile' for details", vim.log.levels.WARN) - end -- quiescent means the full set of results is ready. - if not result.quiescent or _ran_once[ctx.client_id] then + if not result or not result.quiescent then + return + end + -- notify of LSP errors/warnings + if result.health and result.health ~= 'ok' then + local message = ([[ +rust-analyzer health status is [%s]: +%s +Run ':RustLsp logFile' for details. +]]):format(result.health, result.message or '[unknown error]') + vim.notify(message, vim.log.levels.WARN) + end + -- deduplicate messages. + if _ran_once[ctx.client_id] then return end -- rust-analyzer may provide incomplete/empty inlay hints by the time Neovim