refactor(diagnostic): make display handlers generic (#16137)

Rather than treating virtual_text, signs, and underline specially,
introduce the concept of generic "handlers", of which those three are
simply the defaults bundled with Nvim. Handlers are called in
`vim.diagnostic.show()` and `vim.diagnostic.hide()` and are used to
handle how diagnostics are displayed.
This commit is contained in:
Gregory Anders
2021-10-29 19:47:34 -06:00
committed by GitHub
parent 4472c56d54
commit e921e98ce3
5 changed files with 433 additions and 1019 deletions

View File

@ -146,7 +146,8 @@ local _client_namespaces = {}
function M.get_namespace(client_id)
vim.validate { client_id = { client_id, 'n' } }
if not _client_namespaces[client_id] then
local name = string.format("vim.lsp.client-%d", client_id)
local client = vim.lsp.get_client_by_id(client_id)
local name = string.format("vim.lsp.%s.%d", client.name, client_id)
_client_namespaces[client_id] = vim.api.nvim_create_namespace(name)
end
return _client_namespaces[client_id]