-
Notifications
You must be signed in to change notification settings - Fork 6
diagnostics
Zeioth edited this page Mar 31, 2024
·
5 revisions
You can add this component to the statusline section of heirline opts.
require("heirline-components.all").component.diagnostics()
You can see how this component look on the left of the next image: It displays the errors, warnings, and info of your current buffer when a linter is enabled on Neovim.
If you click this area, it will list all the diagnostics of the current buffer.
These are the available providers for this component and its options.
ERROR = {icon = { kind = "DiagnosticError", padding = { left = 1, right = 1 } },}, -- if set, it will display icon+number of errors.
WARN = {icon = { kind = "DiagnosticWarn", padding = { left = 1, right = 1 } },}, -- if set, it will display icon+number of warnings.
INFO = {icon = { kind = "DiagnosticInfo", padding = { left = 1, right = 1 } },}, -- if set, it will display icon+number of info.
HINT = {icon = { kind = "DiagnosticHint", padding = { left = 1, right = 1 } },}, -- if set, it will display icon+number of hints.
surround = {
separator = "left", -- where to add the separator.
color = "diagnostics_bg", -- you can set a custom background color, for example "#444444".
condition = require("heirline-components.all").condition.has_diagnostics -- a function that determines when to display the component.
},
hl = hl.get_attributes "diagnostics", -- you can specify your own highlight group here.
on_click = { name = "<your_event_name", callback = function() end } -- what happens when you click the component.
update = { "DiagnosticChanged", "BufEnter" }, -- events that make the component refresh.
For example you could explicitly disable all the providers of this component except errors.
component.diagnostics({ ERROR = {}, WARN = false, INFO = false, HINT = false })