Skip to content

Commit

Permalink
feat(lsp): more information on LSP errors (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
edevil authored Sep 19, 2024
1 parent 5c0c441 commit 4786724
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lua/rustaceanvim/config/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 14 additions & 4 deletions lua/rustaceanvim/server_status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4786724

Please sign in to comment.