aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/diagnostic.lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2021-11-05 10:10:27 -0600
committerGitHub <noreply@github.com>2021-11-05 10:10:27 -0600
commit1fdbd29dfa6366f8346693d0bf67f4f782ab0f32 (patch)
tree03597b9192e26a4ee04f636738028820096d42d9 /runtime/lua/vim/lsp/diagnostic.lua
parentc0ba315b54a7204efdef71965d156ba5238b1e9a (diff)
downloadrneovim-1fdbd29dfa6366f8346693d0bf67f4f782ab0f32.tar.gz
rneovim-1fdbd29dfa6366f8346693d0bf67f4f782ab0f32.tar.bz2
rneovim-1fdbd29dfa6366f8346693d0bf67f4f782ab0f32.zip
fix(diagnostic): handle an unknown or missing client (#16242)
Sometimes plugins use pseudo-client IDs (e.g. nvim-lint or null-ls) in order to hook into the LSP infrastructure without being a bona fide LSP client. In these cases, get_client_by_id() will return nil since the client ID given does not correspond to a real client recognized by the LSP subsystem. When this happens, use "unknown" for the client name.
Diffstat (limited to 'runtime/lua/vim/lsp/diagnostic.lua')
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index 6b856a52a5..1e6f83c1ba 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -147,7 +147,7 @@ function M.get_namespace(client_id)
vim.validate { client_id = { client_id, 'n' } }
if not _client_namespaces[client_id] then
local client = vim.lsp.get_client_by_id(client_id)
- local name = string.format("vim.lsp.%s.%d", client.name, client_id)
+ local name = string.format("vim.lsp.%s.%d", client and client.name or "unknown", client_id)
_client_namespaces[client_id] = vim.api.nvim_create_namespace(name)
end
return _client_namespaces[client_id]