Skip to content

Commit dc897b0

Browse files
committed
fix(lsp): don't show clients with empty diagnostic content in hover
*Problem*: LSP clients that produced no diagnostic results are being shown in the diagnostics hover (e.g. the client name is shown with no results). *Solution*: This PR hides clients with no diagnostic content in the hover summary.
1 parent 99e754a commit dc897b0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

runtime/lua/vim/lsp/buf.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,15 @@ function M.hover(config)
6161
local results1 = {} --- @type table<integer,lsp.Hover>
6262

6363
for client_id, resp in pairs(results) do
64+
--- @type lsp.ResponseError, lsp.Hover
6465
local err, result = resp.err, resp.result
6566
if err then
6667
lsp.log.error(err.code, err.message)
6768
elseif result then
68-
results1[client_id] = result
69+
-- Ensure that there is some non-empty content to display
70+
if result.contents ~= nil and #result.contents > 0 then
71+
results1[client_id] = result
72+
end
6973
end
7074
end
7175

0 commit comments

Comments
 (0)