perf(ui): only enable treesitter folds if the buffer has treesitter highlighting

This commit is contained in:
Folke Lemaitre 2024-11-09 23:33:05 +01:00
parent 24665fc736
commit b9dae57961
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -53,6 +53,11 @@ local skip_check = assert(vim.uv.new_check())
function M.foldexpr() function M.foldexpr()
local buf = vim.api.nvim_get_current_buf() local buf = vim.api.nvim_get_current_buf()
-- no highlight, no foldexpr
if not vim.b[buf].ts_highlight then
return "0"
end
-- still in the same tick and no parser -- still in the same tick and no parser
if M.skip_foldexpr[buf] then if M.skip_foldexpr[buf] then
return "0" return "0"