Skip to content

treesitter component #70

Answered by rebelot
sibouras asked this question in Q&A
Oct 8, 2022 · 1 comments · 7 replies
Discussion options

You must be logged in to vote

I think there's no need to check if TS is installed each time the status line is refreshed. Instead, you could check it only once outside the component. The valid update autocmd would be OptionSet syntax. Because conditions are evaluated regardless of a valid cache, you can also move the condition inside the provider to remove any operation on component evaluation.

local ts_avail, ts = pcall(require, "nvim-treesitter.parsers")

local TreesitterActive = {
  update = {
    "OptionSet",
    pattern = "syntax"
  }

  provider = function()
    if not (ts_avail and ts.has_parser()) then return end
    local buf = vim.api.nvim_get_current_buf()
    local highlighter = require("vim.treesitter.hig…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@sibouras
Comment options

@rebelot
Comment options

@sibouras
Comment options

@rebelot
Comment options

@sibouras
Comment options

Answer selected by sibouras
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants