summaryrefslogtreecommitdiff
path: root/lua/nvim-treesitter
diff options
context:
space:
mode:
authorMunif Tanjim <hello@muniftanjim.dev>2021-07-08 23:08:06 +0600
committerStephan Seitz <stephan.lauf@yahoo.de>2021-07-08 21:42:02 +0200
commit97761acaff346bb7d2350ee0c6d42012fe5985b6 (patch)
tree5de70e43a4d7847c54c31fad06c368c5e34c012c /lua/nvim-treesitter
parent61411b27c5e7a9539d0974583df8b6522eb89140 (diff)
Folds: support 'foldminlines'
Diffstat (limited to 'lua/nvim-treesitter')
-rw-r--r--lua/nvim-treesitter/fold.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/lua/nvim-treesitter/fold.lua b/lua/nvim-treesitter/fold.lua
index 1d635bfd..2502f717 100644
--- a/lua/nvim-treesitter/fold.lua
+++ b/lua/nvim-treesitter/fold.lua
@@ -37,6 +37,8 @@ local folds_levels = tsutils.memoize_by_buf_tick(function(bufnr)
local prev_start = -1
local prev_stop = -1
+ local min_fold_lines = api.nvim_win_get_option(0, "foldminlines")
+
for _, node in ipairs(matches) do
local start, _, stop, stop_col = node.node:range()
@@ -45,7 +47,7 @@ local folds_levels = tsutils.memoize_by_buf_tick(function(bufnr)
end
local fold_length = stop - start + 1
- local should_fold = fold_length >= 2
+ local should_fold = fold_length > min_fold_lines
-- Fold only multiline nodes that are not exactly the same as previously met folds
-- Checking against just the previously found fold is sufficient if nodes