[Bug] The cmdheight reset to 1 after SessionLoad
adoyle-h opened this issue · comments
I set vim.o.cmdheight=2
in my init.lua
and the cmdheight
is 2 when enter the nvim. But it will be set to 1 after open session (by SessionLoad
).
Before SessionLoad
, :verb set cmdheight
shows,
cmdheight=2
Last set from Lua
After SessionLoad
, :verb set cmdheight
shows,
cmdheight=1
Last set from Lua
Notice: When a session saved two or more buffers, cmdheight will be set to 1. If a session saved only 1 buffer, the cmdheight
is still be 2.
I have disabled all plugins except persisted.nvim. So I am sure this issue is related with persisted.nvim.
The cmdheight
won't be set to 1 when open files directly with nvim file
and nvim -o file1 file2
.
My environment
nvim version: NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3
persisted.nvim version: commit 587b90b
My persisted.nvim options:
{
silent = false, -- silent nvim message when sourcing session file
use_git_branch = true, -- create session files based on the branch of the git enabled repository
autosave = true, -- automatically save session files when exiting Neovim
}
My sessionoptions
vim option: curdir,folds,tabpages,winpos
Sesssion file
For example, it is the sesssion file which saved two buffers.
let SessionLoad = 1
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
let v:this_session=expand("<sfile>:p")
silent only
silent tabonly
cd ~/.local/share/nvim/plugins/trouble.nvim
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
let s:wipebuf = bufnr('%')
endif
let s:shortmess_save = &shortmess
if &shortmess =~ 'A'
set shortmess=aoOA
else
set shortmess=aoO
endif
badd +0 README.md
badd +0 CHANGELOG.md
argglobal
%argdel
edit CHANGELOG.md
let s:save_splitbelow = &splitbelow
let s:save_splitright = &splitright
set splitbelow splitright
wincmd _ | wincmd |
split
1wincmd k
wincmd w
let &splitbelow = s:save_splitbelow
let &splitright = s:save_splitright
wincmd t
let s:save_winminheight = &winminheight
let s:save_winminwidth = &winminwidth
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
wincmd =
argglobal
balt README.md
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let &fdl = &fdl
let s:l = 3 - ((2 * winheight(0) + 9) / 18)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 3
normal! 0
wincmd w
argglobal
if bufexists(fnamemodify("README.md", ":p")) | buffer README.md | else | edit README.md | endif
if &buftype ==# 'terminal'
silent file README.md
endif
balt CHANGELOG.md
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let &fdl = &fdl
let s:l = 1 - ((0 * winheight(0) + 9) / 18)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 1
normal! 0
wincmd w
wincmd =
tabnext 1
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20
let &shortmess = s:shortmess_save
let &winminheight = s:save_winminheight
let &winminwidth = s:save_winminwidth
let s:sx = expand("<sfile>:p:r")."x.vim"
if filereadable(s:sx)
exe "source " . fnameescape(s:sx)
endif
let &g:so = s:so_save | let &g:siso = s:siso_save
set hlsearch
nohlsearch
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :
Thank you for raising. Will look into this during the week. I'll be surprised if this is plugin related as we're mostly using core Vim functionality at load.
Notice: When a session saved two or more buffers, cmdheight will be set to 1. If a session saved only 1 buffer, the cmdheight is still be 2.
You should save session with 2 buffers (vsplit
or split
) to reproduce this issue.
The minimal.lua file.
vim.opt.sessionoptions = { 'curdir', 'folds', 'tabpages', 'winpos' }
vim.opt.cmdheight = 2
vim.opt.rtp:prepend('~/.local/share/nvim/plugins/persisted.nvim/')
require('persisted').setup {}
Open neovim with nvim -u ./minimal.lua
.
@adoyle-h. Struggling to reproduce this now, I've just tried with the following config and two buffers written into a session.
local root = "/tmp/persisted"
-- Set stdpaths to use root dir
for _, name in ipairs({ "config", "data", "state", "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)
vim.opt.sessionoptions = { 'curdir', 'folds', 'tabpages', 'winpos' }
vim.opt.cmdheight = 2
-- Install plugins
local plugins = {
{
"olimorris/persisted.nvim",
config = true
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
Screenshot below:
Can you try with my config above?
@olimorris You should use :vs
or :sp
to open two buffers in same screen to reproduce this issue.
You don't need plugin manager to install plugin. Just use git clone <dir>
to download plugin. And add the <dir>
to vim.opt.rtp
.
vim.opt.sessionoptions = { 'curdir', 'folds', 'tabpages', 'winpos' }
vim.opt.cmdheight = 2
vim.opt.rtp:prepend('~/.local/share/nvim/plugins/persisted.nvim/') -- git clone directory
require('persisted').setup {}
This my record.
Okay sorry. Long day yesterday. So I can recreate this bug without persisted and using native vim commands:
vim.opt.sessionoptions = { 'curdir', 'folds', 'tabpages', 'winpos' }
vim.opt.cmdheight = 2
Creating the session
Sourcing the session
Can you test the same and then I propose one of us raises an issue in Neovim core.
Yes. I reproduce it with your codes. Thank you so much. @olimorris
@adoyle-h I've now raised this neovim/neovim#22450
Emmm.... I raised it too. 😅
Haha damn. Who's written the cleaner issue? 🤣🤣🤣
I think mine is better. I test it with { 'options', 'localoptions' }
, and get the same issue.