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 diagnostics api #219

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ componentizes Vim's statusline by having a provider for each text area.
This means you can use the api provided by galaxyline to create the statusline
that you want, easily.

**Requires neovim 0.5.0+**
**Requires neovim 0.6.0+**

## Install
* vim-plug
Expand Down Expand Up @@ -90,7 +90,7 @@ local buffer = require('galaxyline.provider_buffer')
local whitespace = require('galaxyline.provider_whitespace')
local lspclient = require('galaxyline.provider_lsp')

-- provider
-- provider
BufferIcon = buffer.get_buffer_type_icon,
BufferNumber = buffer.get_buffer_number,
FileTypeName = buffer.get_buffer_filetype,
Expand Down Expand Up @@ -133,7 +133,7 @@ local condition = require('galaxyline.condition')
condition.buffer_not_empty -- if buffer not empty return true else false
condition.hide_in_width -- if winwidth(0)/ 2 > 40 true else false
-- find git root, you can use this to check if the project is a git workspace
condition.check_git_workspace()
condition.check_git_workspace()

-- built-in theme
local colors = require('galaxyline.theme').default
Expand Down
14 changes: 5 additions & 9 deletions lua/galaxyline/provider_diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ local function get_nvim_lsp_diagnostic(diag_type)
local active_clients = lsp.get_active_clients()

if active_clients then
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)
end
local count = #vim.diagnostic.get(api.nvim_get_current_buf(),{severity=diag_type})

if count ~= 0 then return count .. ' ' end
end
Expand All @@ -32,7 +28,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 +37,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 +46,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 +55,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