-
Notifications
You must be signed in to change notification settings - Fork 529
Open
Labels
new featureNew feature or feature requestNew feature or feature request
Description
Requested feature
Neovim just merged neovim/neovim#33723. The vim.diagnostic.status() function m ay be useful. It seems to render the same way as the current nvim_diagnostic, though that appears to be more flexible:
lualine.nvim/lua/lualine/components/diagnostics/sources.lua
Lines 35 to 56 in a94fc68
| nvim_diagnostic = function() | |
| local count | |
| if vim.diagnostic.count ~= nil then -- neovim >= 0.10.0 | |
| count = vim.diagnostic.count(0) | |
| return count[vim.diagnostic.severity.ERROR] or 0, | |
| count[vim.diagnostic.severity.WARN] or 0, | |
| count[vim.diagnostic.severity.INFO] or 0, | |
| count[vim.diagnostic.severity.HINT] or 0 | |
| end | |
| -- fallback | |
| local diagnostics = vim.diagnostic.get(0) | |
| count = { 0, 0, 0, 0 } | |
| for _, diagnostic in ipairs(diagnostics) do | |
| count[diagnostic.severity] = count[diagnostic.severity] + 1 | |
| end | |
| return count[vim.diagnostic.severity.ERROR], | |
| count[vim.diagnostic.severity.WARN], | |
| count[vim.diagnostic.severity.INFO], | |
| count[vim.diagnostic.severity.HINT] | |
| end, |
Also interesting is that this change seems to force/issue a redraw command when diagnostics change. If lualine also registers that, it would improve performance to no longer do it.
Motivation
It may simplify code.
jiangyinzuo and yilinfang
Metadata
Metadata
Assignees
Labels
new featureNew feature or feature requestNew feature or feature request