Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Status Column Breaks in non main split after Session Restore #52

Open
3 tasks done
Shadorain opened this issue Mar 23, 2024 · 1 comment
Open
3 tasks done
Labels
bug Something isn't working

Comments

@Shadorain
Copy link

Did you check the docs and existing issues?

  • I have read the docs
  • 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

  1. Setup statuscol.nvim
  2. Save a session with splits
  3. Exit
  4. Start vim with no arguments
  5. 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:
image

What it looks like after breaking:
image

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?

  • I have confirmed that the bug reproduces with nvim -u repro.lua using the repro.lua file above.
@Shadorain Shadorain added the bug Something isn't working label Mar 23, 2024
@radlinskii
Copy link

radlinskii commented Jul 4, 2024

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.

Screenshot 2024-07-04 at 19 27 10

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 return keywords 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants