File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 122122function M .has_diagnostics (bufnr )
123123 if type (bufnr ) == " table" then bufnr = bufnr .bufnr end
124124 if package.loaded [" astrolsp" ] and require (" astrolsp" ).config .features .diagnostics_mode == 0 then return false end
125- return # vim .diagnostic .get (bufnr or 0 ) > 0
125+ -- TODO: remove when dropping support for neovim 0.9
126+ if vim .diagnostic .count then
127+ return vim .tbl_contains (vim .diagnostic .count (bufnr or 0 ), function (v ) return v > 0 end , { predicate = true })
128+ else
129+ return # vim .diagnostic .get (bufnr or 0 ) > 0
130+ end
126131end
127132
128133--- A condition function if there is a defined filetype
Original file line number Diff line number Diff line change @@ -452,7 +452,13 @@ function M.diagnostics(opts)
452452 if not opts or not opts .severity then return end
453453 return function (self )
454454 local bufnr = self and self .bufnr or 0
455- local count = # vim .diagnostic .get (bufnr , opts .severity and { severity = vim .diagnostic .severity [opts .severity ] })
455+ local count
456+ -- TODO: remove when dropping support for neovim 0.9
457+ if vim .diagnostic .count then
458+ count = vim .diagnostic .count (bufnr )[vim .diagnostic .severity [opts .severity ]] or 0
459+ else
460+ count = # vim .diagnostic .get (bufnr , opts .severity and { severity = vim .diagnostic .severity [opts .severity ] })
461+ end
456462 return status_utils .stylize (count ~= 0 and tostring (count ) or " " , opts )
457463 end
458464end
You can’t perform that action at this time.
0 commit comments