Skip to content

Commit

Permalink
feat(concealer): add option for opening all folds by default
Browse files Browse the repository at this point in the history
  • Loading branch information
champignoom committed Sep 4, 2023
1 parent 20502e5 commit 5de2c79
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lua/neorg/modules/core/concealer/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,11 @@ module.config.public = {
-- Set to `false` if you do not want Neorg setting anything.
folds = true,

-- When set to `auto`, Neorg will open all folds when opening new documents if `foldlevel` is 0.
-- When set to `always`, Neorg will always open all folds when opening new documents.
-- When set to `never`, Neorg will not do anything.
init_open_folds = "auto",

-- Configuration for icons.
--
-- This table contains the full configuration set for each icon, including
Expand Down Expand Up @@ -1261,6 +1266,23 @@ local function handle_init_event(event)
"v:lua.require'neorg'.modules.get_module('core.concealer').foldtext()",
opts
)

local init_open_folds = module.config.public.init_open_folds
local function open_folds() vim.cmd("normal! zR") end

if init_open_folds == "always" then
vim.cmd("normal! zR")
elseif init_open_folds == "never" then
else
if init_open_folds ~= "auto" then
log.warn('"init_open_folds" must be "auto", "always", or "never"')
end

local foldlevel = vim.api.nvim_get_option_value("foldlevel", opts)
if foldlevel == 0 then
open_folds()
end
end
end
end

Expand Down

0 comments on commit 5de2c79

Please sign in to comment.