bug: Status Column Breaks in non main split after Session Restore
Did you check the docs and existing issues?
- [X] I have read the docs
- [X] I have searched the existing issues
Neovim version (nvim -v)
v0.10.0-dev-2582+g2a8cef6bd
Operating system/version
Arch Linux
Describe the bug
I am using the StatusCol plugin and have saved some sessions with splits (majority of my nvim usage) and added "statuscolumn" to the options field in resession config but when exiting nvim and reenterring and loading the session only the buffer that is active (with cursor) has the proper statuscolumn, the others get broken and out of order again.
What is the severity of this bug?
tolerable (can work around it)
Steps To Reproduce
- Setup statuscol.nvim
- Save a session with splits
- Exit
- Start vim with no arguments
- Reload session
When trying to reproduce with repro.lua, i noticed this mainly breaks when starting vim with no arguments at all.
Expected Behavior
It should open with the proper statuscolumn.
What it should look like:
What it looks like after breaking:
Directory structure
Any
Repro
-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
"folke/tokyonight.nvim",
{
"stevearc/resession.nvim",
config = function()
require("resession").setup({
-- add any needed settings here
options = {
"binary",
"bufhidden",
"buflisted",
"cmdheight",
"diff",
"filetype",
"modifiable",
"previewwindow",
"readonly",
"scrollbind",
"winfixheight",
"winfixwidth",
"statuscolumn",
},
-- override default filter
buf_filter = function(bufnr)
local buftype = vim.bo[bufnr].buftype
if buftype == "help" then
return true
end
if buftype ~= "" and buftype ~= "acwrite" then
return false
end
if vim.api.nvim_buf_get_name(bufnr) == "" then
return false
end
-- this is required, since the default filter skips nobuflisted buffers
return true
end,
extensions = { scope = {}, overseer = {} },
})
end,
},
-- add any other plugins here
{
"kevinhwang91/nvim-ufo",
event = { "BufReadPost", "BufNewFile" },
dependencies = {
{
"luukvbaal/statuscol.nvim",
dependencies = "kevinhwang91/promise-async",
config = function()
local builtin = require("statuscol.builtin")
require("statuscol").setup({
ft_ignore = { "neo-tree", "Outline" },
segments = {
{ sign = { namespace = { "diagnostic*" } } },
{ sign = { namespace = { "gitsigns" } }, click = "v:lua.ScSa" },
{ text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
{ text = { builtin.foldfunc, " " }, click = "v:lua.ScFa" },
},
})
end,
},
},
init = function()
vim.o.foldcolumn = "1"
vim.o.foldlevel = 99
vim.o.foldlevelstart = 99
vim.o.foldenable = true
end,
config = function()
vim.keymap.set("n", "zR", require("ufo").openAllFolds)
vim.keymap.set("n", "zM", require("ufo").closeAllFolds)
vim.keymap.set("n", "zr", require("ufo").openFoldsExceptKinds)
vim.keymap.set("n", "zm", require("ufo").closeFoldsWith)
require("ufo").setup({
provider_selector = function()
return { "treesitter", "indent" }
end,
})
end,
},
{
"lewis6991/gitsigns.nvim",
ft = { "gitcommit", "diff" },
init = function()
vim.api.nvim_create_autocmd({ "BufRead" }, {
group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }),
callback = function()
vim.fn.jobstart({ "git", "-C", vim.loop.cwd(), "rev-parse" }, {
on_exit = function(_, return_code)
if return_code == 0 then
vim.api.nvim_del_augroup_by_name("GitSignsLazyLoad")
vim.schedule(function()
require("lazy").load({ plugins = { "gitsigns.nvim" } })
end)
end
end,
})
end,
desc = "Load gitsigns only if git repository",
})
end,
opts = {
signs = {
add = { text = "│" },
change = { text = "│" },
delete = { text = "│" },
topdelete = { text = "│" },
changedelete = { text = "│" },
untracked = { text = "┆" },
},
preview_config = {
border = "rounded",
},
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map("n", "]c", function()
if vim.wo.diff then
return "]c"
end
vim.schedule(function()
gs.next_hunk()
end)
return "<Ignore>"
end, { expr = true })
map("n", "[c", function()
if vim.wo.diff then
return "[c"
end
vim.schedule(function()
gs.prev_hunk()
end)
return "<Ignore>"
end, { expr = true })
end,
},
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
vim.o.number = true
vim.o.relativenumber = true
vim.o.ruler = false
vim.o.termguicolors = true
vim.g.mapleader = " "
local resession = require("resession")
resession.setup()
-- Resession does NOTHING automagically, so we have to set up some keymaps
vim.keymap.set("n", "<leader>ss", resession.save)
vim.keymap.set("n", "<leader>sl", resession.load)
vim.keymap.set("n", "<leader>sd", resession.delete)
Did you check the bug with a clean config?
- [X] I have confirmed that the bug reproduces with
nvim -u repro.luausing the repro.lua file above.
I have the same issue, with status column being broken after loading the session, but I am using default config for ressession, additionally the file in the split is always folded.
I am also using nvim-ufo.
- additionally the split window has correct highlights, but the main window has not. You can only compare on the picture that the
returnkeywords have different colours, although they should be the same (red).
I'm at recession commit e087ebe.
nvim -v:
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1716656478
Run "nvim -V1 -v" for more info
Happens on both macOS and Windows.