Files
outline.nvim/lua/outline/folding.lua
2023-11-19 22:35:07 +08:00

36 lines
854 B
Lua

local M = {}
local cfg = require('outline.config')
---@param node outline.SymbolNode|outline.FlatSymbolNode
function M.is_foldable(node)
return node.children and #node.children > 0
end
---@param depth integer
local function get_default_folded(depth)
local fold_past = cfg.o.symbol_folding.autofold_depth
if not fold_past then
return false
else
return depth >= fold_past
end
end
---@param node outline.SymbolNode|outline.FlatSymbolNode
function M.is_folded(node)
local hover = cfg.o.symbol_folding.auto_unfold_hover
local only = cfg.o.symbol_folding.auto_unfold.only
if node.folded ~= nil then
return node.folded
elseif node.parent.is_root and node.parent.child_count <= only then
return false
elseif node.hovered and hover then
return false
else
return get_default_folded(node.depth)
end
end
return M