Skip to content

treesitter

Zeioth edited this page Apr 3, 2024 · 7 revisions

You can add this component to the statusline section of heirline opts.

require("heirline-components.all").component.treesitter()

It displays a indicator when treesitter is available. screenshot_2024-02-23_18-37-00_278637378

Available providers

These are the available providers for this component and its options.

str = { str = "TS", icon = { kind = "ActiveTS", padding = { right = 1 } } },      -- String and icon to display.
surround = {
  separator = "right",                                                            -- where to add the separator.
  color = "treesitter_bg",                                                        -- you can set a custom background color, for example "#444444".
  condition = require("heirline-components.all").condition.treesitter_available   -- 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 = { "OptionSet", pattern = "syntax" },                                     -- events that make the component refresh.
init = init.update_events { "BufEnter" }

For example you could change the text displayed when treesitter is enabled

component.treesitter({ str = { str = { str = "Treesitter ON" } } })