commit 03f944b0fe6d1f56da96c0eb929be32e3616b521
parent 016335a7d09fca82cd6065ca4f54101c27249d01
Author: Pig Fang <g-plane@hotmail.com>
Date: Tue, 2 Dec 2025 17:41:11 +0800
refactor(lsp): fix lint
Diffstat:
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
@@ -396,11 +396,14 @@ function M.on_refresh(err, _, ctx)
return vim.NIL
end
local client = vim.lsp.get_client_by_id(ctx.client_id)
+ if client == nil then
+ return vim.NIL
+ end
if
client.server_capabilities.diagnosticProvider
and client.server_capabilities.diagnosticProvider.workspaceDiagnostics
then
- M._workspace_diagnostics(ctx)
+ M._workspace_diagnostics({ client_id = ctx.client_id })
else
for bufnr in pairs(client.attached_buffers or {}) do
if bufstates[bufnr] and bufstates[bufnr].pull_kind == 'document' then
diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua
@@ -661,7 +661,7 @@ describe('vim.lsp.diagnostic', function()
eq(1, #diags)
eq(1, diags[1].severity)
- local requests, diags = exec_lua(function()
+ local requests, refreshed_diags = exec_lua(function()
vim.lsp.diagnostic.on_refresh(nil, nil, {
method = 'workspace/diagnostic/refresh',
client_id = client_id,
@@ -670,8 +670,8 @@ describe('vim.lsp.diagnostic', function()
return _G.requests, vim.diagnostic.get(diagnostic_bufnr)
end)
eq(1, requests)
- eq(1, #diags)
- eq(2, diags[1].severity)
+ eq(1, #refreshed_diags)
+ eq(2, refreshed_diags[1].severity)
end)
it('refreshes workspace diagnostics', function()
@@ -703,10 +703,12 @@ describe('vim.lsp.diagnostic', function()
client_id = vim.lsp.start({ name = 'dummy', cmd = _G.server.cmd })
end)
- local diags = exec_lua(function()
- return vim.diagnostic.get()
- end)
- eq(0, #diags)
+ eq(
+ 0,
+ exec_lua(function()
+ return #vim.diagnostic.get()
+ end)
+ )
local requests, diags = exec_lua(function()
vim.lsp.diagnostic.on_refresh(nil, nil, {