olimorris / persisted.nvim

💾 Simple session management for Neovim with git branching, autoloading and Telescope support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Howto ignore dirs "~" but not "~/*"?

tmpm697 opened this issue · comments

I want to ignore user's home dir specifically but not whatever dirs under that home, so when i at home cd ~ and start nvim, this session will be ignored.

but when i do like cd ~/.config/nvim; nvim then the session for ~/.config/nvim will not be ignored.

howto?

The workaround for now is you could ignore saving session on dashboard or empty buffer.
Example: https://github.com/latipun7/dotfiles/blob/main/home/dot_config/exact_lvim/exact_lua/exact_latipun/exact_plugins/persisted.lua#L20-L24

commented

Yes as @latipun7 correctly refers to in their post, the should_autosave callback is the best way to deal with this. You could check for the current workin directory and if it matches ~ then return false.