mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-05 21:10:15 -04:00
docs(fold): document and comment
This commit is contained in:
parent
d5e11c41cf
commit
03621e758c
2 changed files with 10 additions and 0 deletions
|
|
@ -5,6 +5,8 @@ local parsers = require'nvim-treesitter.parsers'
|
|||
|
||||
local M = {}
|
||||
|
||||
-- This is cached on buf tick to avoid computing that multiple times
|
||||
-- Especially not for every line in the file when `zx` is hit
|
||||
local folds_levels = utils.memoize_by_buf_tick(function(bufnr)
|
||||
local lang = parsers.get_buf_lang(bufnr)
|
||||
|
||||
|
|
@ -38,10 +40,12 @@ local folds_levels = utils.memoize_by_buf_tick(function(bufnr)
|
|||
local levels = {}
|
||||
local current_level = 0
|
||||
|
||||
-- We now have the list of fold opening and closing, fill the gaps and mark where fold start
|
||||
for lnum=0,api.nvim_buf_line_count(bufnr) do
|
||||
local prefix= ''
|
||||
local shift = levels_tmp[lnum] or 0
|
||||
|
||||
-- Determine if it's the start of a fold
|
||||
if levels_tmp[lnum] and shift >= 0 then
|
||||
prefix = '>'
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue