Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated vim.lsp.diagnostic.get_count call #226

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch gives arithmetic errors when displaying the diagnostics at the galaxystatus line.

I may be wrong, but aren't you here adding a scalar count to a table from vim.diagnostic.get().

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed this in my fork if you're interested.
https://github.com/justinhj/galaxyline.nvim/blob/main/README.md

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