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
12
12
13
13
local is_setup = false
14
14
local lsp_bufs = {}
15
+ local ts_bufs = {}
15
16
16
17
local fold_methods = {
17
18
lsp = function (lnum , bufnr )
18
19
if lsp_bufs [bufnr or vim .api .nvim_get_current_buf ()] then return vim .lsp .foldexpr (lnum ) end
19
20
end ,
20
21
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
22
26
end ,
23
27
indent = function (lnum , bufnr )
24
28
if not lnum then lnum = vim .v .lnum end
You can’t perform that action at this time.
0 commit comments