folke / persistence.nvim

💾 Simple session management for Neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

autocmd to start session automatically

lauccode opened this issue · comments

I'm not familiar at all with autocmd.
You say "It will never restore a session automatically, but you can of course write an autocmd that does exactly that if you want."
Please, what should be this autocmd for "restore the session for the current directory" ? (I'm on lunarvim)

Maybe this could be added as an option ?
For me this is a must have. Because when working a many files it is really easier to have all open automatically.
When I need to do it myself, sometimes I forget. And I loose all for the next time.

For what it's worth, I've been using this one.

vim.api.nvim_create_autocmd("VimEnter", {
  group = vim.api.nvim_create_augroup("persistence", { clear = true }),
  callback = function()
    require("persistence").load()
  end,
})

Though it seems like filetype isn't set for any active buffers until I run :e on each one. Hidden buffers work just fine, though.

You can just use a keymap to restore the last session or the session from the directory. That's how I use persistence.

I'm not planning on addding any other options to persisted. There's a ton of other plugins out there that provide that functionality out of the box (including forks of persisted)