Use new diagnostic API

Fix #29
This commit is contained in:
Olivier Roques
2021-12-10 20:27:30 +01:00
parent 3ed48995e6
commit 0a002a8b80
2 changed files with 13 additions and 5 deletions

View File

@@ -1,8 +1,17 @@
local lsp = vim.lsp
local diagnostic, fn, lsp = vim.diagnostic, vim.fn, vim.lsp
local fmt = string.format
local function get_diagnostic(prefix, severity)
local count = lsp.diagnostic.get_count(0, severity)
local count
if fn.has('nvim-0.6') == 0 then
count = lsp.diagnostic.get_count(0, severity)
else
local severities = {
['Warning'] = diagnostic.severity.WARNING,
['Error'] = diagnostic.severity.ERROR,
}
count = #diagnostic.get(0, {severity=severities[severity]})
end
if count < 1 then
return ''
end