Skip to content

Commit

Permalink
feat(concealer): add option for opening all folds by default (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
champignoom committed Sep 6, 2023
1 parent b4c7935 commit 6bfcaeb
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
open_folds()
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 6bfcaeb

Please sign in to comment.