Skip to content

Commit

Permalink
Fix deprecated vim.lsp.diagnostic.get_count call
Browse files Browse the repository at this point in the history
  • Loading branch information
Drake Nelson authored and CHNB128 committed Jan 14, 2022
1 parent d544cb9 commit 1c7bfe9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lua/galaxyline/provider_diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ local function get_nvim_lsp_diagnostic(diag_type)
local count = 0

for _, client in ipairs(active_clients) do
count = count + lsp.diagnostic.get_count(api.nvim_get_current_buf(),diag_type,client.id)
local opts = { severity = diag_type }
opts.namespace = vim.diagnostic.get_namespace(client.id)
count = count + vim.diagnostic.get(api.nvim_get_current_buf(),opts)
end

if count ~= 0 then return count .. ' ' end
Expand All @@ -32,7 +34,7 @@ function M.get_diagnostic_error()
if vim.fn.exists('*coc#rpc#start_server') == 1 then
return get_coc_diagnostic('error')
elseif not vim.tbl_isempty(lsp.buf_get_clients(0)) then
return get_nvim_lsp_diagnostic('Error')
return get_nvim_lsp_diagnostic(vim.diagnostic.severity.ERROR)
end
return ''
end
Expand All @@ -41,7 +43,7 @@ function M.get_diagnostic_warn()
if vim.fn.exists('*coc#rpc#start_server') == 1 then
return get_coc_diagnostic('warning')
elseif not vim.tbl_isempty(lsp.buf_get_clients(0)) then
return get_nvim_lsp_diagnostic('Warning')
return get_nvim_lsp_diagnostic(vim.diagnostic.severity.WARN)
end
return ''
end
Expand All @@ -50,7 +52,7 @@ function M.get_diagnostic_hint()
if vim.fn.exists('*coc#rpc#start_server') == 1 then
return get_coc_diagnostic('hint')
elseif not vim.tbl_isempty(lsp.buf_get_clients(0)) then
return get_nvim_lsp_diagnostic('Hint')
return get_nvim_lsp_diagnostic(vim.diagnostic.severity.HINT)
end
return ''
end
Expand All @@ -59,7 +61,7 @@ function M.get_diagnostic_info()
if vim.fn.exists('*coc#rpc#start_server') == 1 then
return get_coc_diagnostic('information')
elseif not vim.tbl_isempty(lsp.buf_get_clients(0)) then
return get_nvim_lsp_diagnostic('Information')
return get_nvim_lsp_diagnostic(vim.diagnostic.severity.INFO)
end
return ''
end
Expand Down

0 comments on commit 1c7bfe9

Please sign in to comment.