mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
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.
This commit is contained in:
parent
c0ba315b54
commit
1fdbd29dfa
@ -147,7 +147,7 @@ function M.get_namespace(client_id)
|
|||||||
vim.validate { client_id = { client_id, 'n' } }
|
vim.validate { client_id = { client_id, 'n' } }
|
||||||
if not _client_namespaces[client_id] then
|
if not _client_namespaces[client_id] then
|
||||||
local client = vim.lsp.get_client_by_id(client_id)
|
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)
|
_client_namespaces[client_id] = vim.api.nvim_create_namespace(name)
|
||||||
end
|
end
|
||||||
return _client_namespaces[client_id]
|
return _client_namespaces[client_id]
|
||||||
|
Loading…
Reference in New Issue
Block a user