Closed orhnk closed 1 year ago
@UTFeight does your folds work correctly when you do not do setlocal nofoldenable
?
Here is how they look without setlocal nofoldenable
:
https://github.com/nvim-orgmode/orgmode/assets/101834410/f7da69cb-299c-4314-b5e2-cc5b58cf5ad0
They do work how they should be now.
But there is no option to set as fold_depth
which I want to see like the following:
[!NOTE] This is
set foldlevel=99
And works exactly how I want it to work. But... (look at the next video)
https://github.com/nvim-orgmode/orgmode/assets/101834410/fb9eee42-3a20-471f-a82c-2f2ca26c3a1e
[!NOTE] Using
set foldlevel=99
loaded after the config, seems to not work?
https://github.com/nvim-orgmode/orgmode/assets/101834410/7068e947-1cce-4a79-aa05-2ed698d3f8c5
for some nice blue switch ASMR, you can unmute videos :D
I have found a solution for this!
adding options after lazy loading the plugin didn't work well so this was happening.
After orgmode is (lazy) loaded (for lazy.nvim It's in config
fn):
-- vim.cmd [[setlocal foldlevel=99]] -- WARNING: DIDN'T WORK!!!
vim.cmd [[setlocal nofoldenable]] -- No folds initially
-- ABOVE SNIPPET IS RAN RIGHT AFTER THE PLUGIN IS LOADED
[!NOTE] Using
foldlevel=99
in lazy'sconfig
fn didn't work. I wonder why?
init.lua
vim.cmd [[autocmd FileType org setlocal foldlevel=99]]
-- (Put that in init.lua if you don't have an option like mine)
vim.cmd [[autocmd FileType org setlocal nofoldenable]] -- No folds initially
vim.cmd [[autocmd FileType org setlocal foldlevel=99]]
Without UFO I can reproduce this issue, I have attached a minimal init.
Just copy and paste that big 'ol beast and run it with nvim -nu MINIMAL_INIT_FILE_NAME.lua
.
It'll show the issue.
Orgmode is overriding the foldlevel
to 0 and doesn't respect the foldlevel
a user may have set. It does that
here.
Ideally Orgmode wouldn't mess with the foldlevel
as it is 0 by default and if a user changed that it really should
respect the custom foldlevel
.
I think I have fixed the issues with UFO
as well by commenting out the fillchars
line as well in the ftplugin file,
link to that.
When both the foldlevel
and fillchars
lines are removed from the ftplugin/org.vim
file, UFO and my foldlevel
settings work as expected.
@kristijanhusak Is there a particular reason Orgmode ignores user configuration of fillchars
& foldlevel
? If so, I'll
see if I can find an alternative work around.
Orgmode is overriding the
foldlevel
to 0 and doesn't respect thefoldlevel
a user may have set. It does that here.
@treatybreaker That looks like a PR!
@treatybreaker I understand why foldlevel
might be an issue, but I'm not sure why would fillchars
cause an issue?
We could introduce org-startup-folded
as described here https://orgmode.org/manual/Initial-visibility.html and have it's value as overview
by default. This value would set foldlevel
to 0
as it does now. This is just to keep everything backward compatible. Valid options would be overview
(foldlevel=0), content
(foldlevel=1), showeverything
(foldlevel=99) and nil
(no foldlevel set). Then we should read this configuration and act accordingly.
@kristijanhusak
So the fillchars
may be more relevant to #599, as the fold
fillchars
interfere with nvim-ufo
's fold chars.
In terms of foldlevel
, would you accept a PR with that variable org-startup-folded
? I'd be more than happy to send it
your way.
Arguably though we don't even need options for that as Neovim has buffer options which a user could set themselves or just the filetype plugin in their after directory to set the foldlevel
. It's basically built-in. The best way to handle this may just be to just not set the foldlevel
at all and mention it in the docs.
In terms of foldlevel, would you accept a PR with that variable org-startup-folded? I'd be more than happy to send it your way.
Yes, please send it over. I'd like to streamline it through configuration.
Describe the bug
Initial setup folds all headers in an org file on startup.
You can disable this by:
With this in you config the headers don't fold anymore but folding works incorrect!
https://github.com/nvim-orgmode/orgmode/assets/101834410/2faa0fbc-c3cd-41e1-9bb4-133f2bffba3e
As you can see:
Steps to reproduce
setlocal nofoldenable
in your configExpected behavior
Wanted to see the
merge-lang
header folded only. (in the video)Emacs functionality
Emacs works as it should
Minimal init.lua
Screenshots and recordings
No response
OS / Distro
archlinux
Neovim version/commit
NVIM v0.10.0-dev-bb38c06 Build type: RelWithDebInfo LuaJIT 2.1.1693350652
Additional context
No response