folke / persistence.nvim

💾 Simple session management for Neovim
Apache License 2.0
638 stars 26 forks source link

autocmd to start session automatically #13

Closed lauccode closed 1 year ago

lauccode commented 1 year ago

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.

dirn commented 1 year ago

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.

folke commented 1 year ago

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)