From 1c7bfe99b698600f441bd3d7e3d09f6d421b8637 Mon Sep 17 00:00:00 2001 From: Drake Nelson Date: Fri, 14 Jan 2022 13:35:43 +0600 Subject: [PATCH] Fix deprecated `vim.lsp.diagnostic.get_count` call --- lua/galaxyline/provider_diagnostic.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/galaxyline/provider_diagnostic.lua b/lua/galaxyline/provider_diagnostic.lua index cebd3bc..48733ee 100644 --- a/lua/galaxyline/provider_diagnostic.lua +++ b/lua/galaxyline/provider_diagnostic.lua @@ -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 @@ -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 @@ -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 @@ -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 @@ -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