File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,17 @@ local config = require("astroui").config.folding
1212
1313local is_setup = false
1414local lsp_bufs = {}
15+ local ts_bufs = {}
1516
1617local fold_methods = {
1718 lsp = function (lnum , bufnr )
1819 if lsp_bufs [bufnr or vim .api .nvim_get_current_buf ()] then return vim .lsp .foldexpr (lnum ) end
1920 end ,
2021 treesitter = function (lnum , bufnr )
21- if vim .bo .filetype and pcall (vim .treesitter .get_parser , bufnr ) then return vim .treesitter .foldexpr (lnum ) end
22+ if ts_bufs [bufnr ] == nil then
23+ ts_bufs [bufnr ] = vim .bo .filetype and pcall (vim .treesitter .get_parser , bufnr ) or false
24+ end
25+ if ts_bufs [bufnr ] then return vim .treesitter .foldexpr (lnum ) end
2226 end ,
2327 indent = function (lnum , bufnr )
2428 if not lnum then lnum = vim .v .lnum end
You can’t perform that action at this time.
0 commit comments