Closed otavioschwanck closed 1 year ago
Does #363 fit the use case? Or is there something different you had in mind?
Does #363 fit the use case? Or is there something different you had in mind?
i think it fits!
@Iron-E i upgraded and the buffer pin is still not being persisted!
Did you :doautocmd User SessionSavePre
, then :mksession foo.vim
(or any other session management command) before exiting? Then to load, nvim -S foo.vim
Did you
:doautocmd User SessionSavePre
, then:mksession foo.vim
(or any other session management command) before exiting? Then to load,nvim -S foo.vim
Im using persistence.nvim. i already testes with bufferline pins and it works.
So it works now? Might be convenient to write a wrapper like this to ensure the autocmd event always gets fired in the future:
vim.api.nvim_create_user_command(
'Mksession',
function()
vim.api.nvim_exec_autocmds('User', {pattern = 'SessionSavePre'})
--[[ session save command here
e.g. `vim.cmd.mksession()`
or persistence.nvim function ]]
end,
{}
)
Edit: interesting. persistence.nvim doesn't have a session save command, it just does everything automatically
Edit 2: found the issue. persistence.nvim overrides your sessionoptions
on save with these:
options = { "buffers", "curdir", "tabpages", "winsize" }
…which are specified when calling persistence.nvim's setup function. You'll need to add "globals"
to this list. As long as persistence.nvim emits SessionLoadPost
you shouldn't need to nvim -S
either.
(Not sure why they do it this way, instead of just reading sessionoptions
directly, but that's neither here nor there)
So it works now? Might be convenient to write a wrapper like this to ensure the autocmd event always gets fired in the future:
vim.api.nvim_create_user_command( 'Mksession', function() vim.api.nvim_exec_autocmds('User', {pattern = 'SessionSavePre'}) --[[ session save command here e.g. `vim.cmd.mksession()` or persistence.nvim function ]] end, {} )
Edit: interesting. persistence.nvim doesn't have a session save command, it just does everything automatically
Edit 2: found the issue. persistence.nvim overrides your
sessionoptions
on save with these:options = { "buffers", "curdir", "tabpages", "winsize" }
…which are specified when calling persistence.nvim's setup function. You'll need to add
"globals"
to this list. As long as persistence.nvim emitsSessionLoadPost
you shouldn't need tonvim -S
either.(Not sure why they do it this way, instead of just reading
sessionoptions
directly, but that's neither here nor there)
im already adding globals to persistence. Not working either.
{
"folke/persistence.nvim",
event = "BufReadPre", -- this will only start session saving when an actual file was opened
module = "persistence",
config = function()
require("persistence").setup({
options = { "buffers", "curdir", "tabpages", "winsize", "globals" }, -- sessionoptions used for saving
})
end,
}
Another thing: The buffer order is not being keep too, maybe is something with the load of barbar?
@otavioschwanck Just double checking that you run :doautocmd User SessionSavePre
before exiting vim.
If so, can you post one of the session files that persistence.nvim is generating? Make sure to censor personally identifying information, I don't need any actual filenames, just the leading setup info.
Since the order of buffers is lost, my guess is that the global barbar session restore variable isn't being stored by persistence.nvim, in which case I'll download the plugin and try it later as well
@otavioschwanck Just double checking that you run
:doautocmd User SessionSavePre
before exiting vim.If so, can you post one of the session files that persistence.nvim is generating? Make sure to censor personally identifying information, I don't need any actual filenames, just the leading setup info.
Since the order of buffers is lost, my guess is that the global barbar session restore variable isn't being stored by persistence.nvim, in which case I'll download the plugin and try it later as well
even using :doautocmd User SessionSavePre it not save.
The session file:
cat %Users%otavio%.config%nvim.vim
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")
let VM_mouse_mappings = 0
let HowMuch_no_mappings = 1
let VM_default_mappings = 1
let VM_persistent_registers = 0
let VM_highlight_matches = "underline"
let VM_check_mappings = 1
let VM_theme = "olive"
silent only
silent tabonly
cd ~/.config/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 lua/plugins/init.lua
argglobal
%argdel
edit lua/plugins/init.lua
argglobal
balt lua/plugins/init.lua
let s:l = 120 - ((22 * winheight(0) + 22) / 45)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 120
normal! 026|
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 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 :
Looks like it's not saving the global variables. I'll open a separate issue with regards to persistence.nvim and investigate later today— in the meantime, manually running :mksession
and nvim -S
should work.
Looks like it's not saving the global variables. I'll open a separate issue with regards to persistence.nvim and investigate later today— in the meantime, manually running
:mksession
andnvim -S
should work.
the session only saves CamelCase variables, another variables are being save like:
:set g:MyVariable='hello'
reset nvim
:echo g:MyVariable
The global variable from barbar are being saved as CamelCase?
Would be nice to have it on barbar.