You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kindly note that I have org_cycle bound to Tab and org_global_cycle bound to S-Tab and every orgmode setting is the defaults.
When opening an org file, headings are folded (as per my org_startup_folded default setting). When I press S-Tab to cycle the folds on all the headlines, it seems to modify Neovim's foldlevel. Then, when I open a new buffer to a non-org file, that foldlevel persists, and the contents of that file are folded. This behavior persists after all org buffers are closed. The behavior also persists when opening the new buffers in split windows.
I observed this only happens with the global cycle command. org_cycle does not cause this behavior.
Steps to reproduce
Note that my foldlevel is set to 99 in my Neovim config.
Open an org file in a buffer.
Press org_global_cycle (S-tab) an arbitrary number of times.
Open a non-org file (such as a lua file) in another buffer.
Observe that the file is displayed with folding.
Close the org buffer.
Open another non-org file.
Observe that the file is still displayed with folding.
Screenshots:
Observation at step 4.
Expected behavior
The org global cycle keybind should only affect org buffers.
Emacs functionality
No response
Minimal init.lua
With the minimal init, you can do :e /tmp/test.org and then :e /tmp/test.lua to reproduce the issue. In the minimal init, the Lua file doesn't fold automatically, but you can observe that set foldlevel does not return 99 after opening test.lua, and it is the foldlevel which is the problem here.
localorg=io.open("/tmp/test.org", "w")
ifnotorgthenerror("failed open org")
endlocalorgc=[[* A headline is here.** TODO This is a task.]]locallua=io.open("/tmp/test.lua", "w")
localluac=[[-- a file from my config that has a lot of folds in it-- this is the file on which I noticed the bugreturn { "folke/snacks.nvim", opts = { toggle = { notify = false, }, bigfile = { notify = true, -- show notification when big file detected size = 1.5 * 1024 * 1024, -- 1.5MB -- Enable or disable features when big file detected ---@param ctx {buf: number, ft:string} setup = function(ctx) -- Snacks.util.wo(0, { foldmethod = "manual", statuscolumn = "", conceallevel = 0 }) -- vim.b.minianimate_disable = true vim.schedule(function() vim.bo[ctx.buf].syntax = ctx.ft end) end, }, zen = { notify = false, toggles = { dim = false, git_signs = false, mini_diff_signs = false, diagnostics = true, inlay_hints = true, }, win = { backdrop = { transparent = false, blend = 20, }, }, }, }, keys = { { "<leader>z", function() Snacks.zen({ win = { backdrop = { transparent = false, blend = 10, }, }, }) end, desc = "Toggle Zen Mode", }, { "<leader>Z", function() Snacks.zen({ win = { backdrop = { transparent = false, }, }, }) end, desc = "Toggle Zen Mode (no backdrop)", }, },}]]org:write(orgc)
lua:write(luac)
localtmp_dir=vim.env.TMPDIRorvim.env.TMPorvim.env.TEMPor"/tmp"localnvim_root=tmp_dir.."/nvim_orgmode"locallazy_root=nvim_root.."/lazy"locallazypath=lazy_root.."/lazy.nvim"for_, nameinipairs({ "config", "data", "state", "cache" }) dovim.env[("XDG_%s_HOME"):format(name:upper())] =nvim_root.."/" ..nameend-- Install lazy.nvim if not already installedifnotvim.loop.fs_stat(lazypath) thenvim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable releaselazypath,
})
endvim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
"nvim-orgmode/orgmode",
event="VeryLazy",
ft= { "org" },
config=function()
require("orgmode").setup()
end,
},
}, {
root=lazy_root,
lockfile=nvim_root.."/lazy.json",
install= {
missing=false,
},
})
require("lazy").sync({
wait=true,
show=false,
})
vim.o.foldlevel=99
ficcdaf
changed the title
The org_global_cycle keybinding affects non-org buffers while an org buffer is open
The org_global_cycle keybinding affects non-org buffers
Jan 19, 2025
Describe the bug
When opening an
org
file, headings are folded (as per myorg_startup_folded
default setting). When I pressS-Tab
to cycle the folds on all the headlines, it seems to modify Neovim'sfoldlevel
. Then, when I open a new buffer to a non-org file, thatfoldlevel
persists, and the contents of that file are folded. This behavior persists after allorg
buffers are closed. The behavior also persists when opening the new buffers in split windows.I observed this only happens with the global cycle command.
org_cycle
does not cause this behavior.Steps to reproduce
Note that my
foldlevel
is set to99
in my Neovim config.org
file in a buffer.org_global_cycle
(S-tab
) an arbitrary number of times.org
file (such as alua
file) in another buffer.org
buffer.org
file.Screenshots:
Expected behavior
The org global cycle keybind should only affect org buffers.
Emacs functionality
No response
Minimal init.lua
With the minimal init, you can do
:e /tmp/test.org
and then:e /tmp/test.lua
to reproduce the issue. In the minimal init, the Lua file doesn't fold automatically, but you can observe thatset foldlevel
does not return99
after openingtest.lua
, and it is thefoldlevel
which is the problem here.Screenshots and recordings
No response
OS / Distro
Arch Linux
Neovim version/commit
NVIM v0.11.0-dev-1589+g71507281fb Build type: RelWithDebInfo LuaJIT 2.1.1736781742
Additional context
No response
The text was updated successfully, but these errors were encountered: