File tree Expand file tree Collapse file tree 4 files changed +26
-1
lines changed Expand file tree Collapse file tree 4 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,15 @@ Applies to:
153153 - agenda window
154154 - capture window
155155
156+ #### ** org_startup_folded**
157+ * type* : ` string ` <br />
158+ * default value* : ` overview ` <br />
159+ How many headings and other foldable items should be shown when an org file is opened.<br />
160+ Available options:
161+ * ` overview ` - Only show top level elements (default)
162+ * ` content ` - Only show the first two levels
163+ * ` showeverything ` - A double line box
164+ * ` inherit ` - Use the fold level set in Neovim's global ` foldlevel ` option
156165
157166#### ** org_todo_keyword_faces**
158167* type* : ` table<string, string> ` <br />
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ let b:did_ftplugin = 1
55
66lua require (' orgmode.config' ): setup_mappings (' org' )
77lua require (' orgmode.config' ): setup_mappings (' text_objects' )
8+ lua require (' orgmode.config' ): setup_foldlevel ()
89
910function ! OrgmodeFoldText ()
1011 return luaeval (' require("orgmode.org.indent").foldtext()' )
@@ -24,7 +25,6 @@ setlocal foldmethod=expr
2425setlocal foldexpr = nvim_treesitter#foldexpr ()
2526setlocal foldtext = OrgmodeFoldText ()
2627setlocal formatexpr = OrgmodeFormatExpr ()
27- setlocal foldlevel = 0
2828setlocal omnifunc = OrgmodeOmni
2929setlocal commentstring = #\ % s
3030inoreabbrev <silent><buffer> :today: <C-R> = luaeval (" require('orgmode.objects.date').today():to_wrapped_string(true)" )<CR>
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ local DefaultConfig = {
1616 template = ' * TODO %?\n %u' ,
1717 },
1818 },
19+ org_startup_folded = ' overview' ,
1920 org_agenda_skip_scheduled_if_done = false ,
2021 org_agenda_skip_deadline_if_done = false ,
2122 org_agenda_text_search_extra_files = {},
Original file line number Diff line number Diff line change @@ -292,6 +292,21 @@ function Config:setup_mappings(category, buffer)
292292 end
293293end
294294
295+ --- Setup the foldlevel for a given org file
296+ function Config :setup_foldlevel ()
297+ if self .org_startup_folded == ' overview' then
298+ vim .opt_local .foldlevel = 0
299+ elseif self .org_startup_folded == ' content' then
300+ vim .opt_local .foldlevel = 1
301+ elseif self .org_startup_folded == ' showeverything' then
302+ vim .opt_local .foldlevel = 99
303+ elseif self .org_startup_folded ~= ' inherit' then
304+ utils .echo_warning (" Invalid option passed for 'org_startup_folded'!" )
305+ self .opts .org_startup_folded = ' overview'
306+ self :setup_foldlevel ()
307+ end
308+ end
309+
295310--- @return string | nil
296311function Config :parse_archive_location (file , archive_loc )
297312 if self :is_archive_file (file ) then
You can’t perform that action at this time.
0 commit comments