Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/folke/persistence.nvim
💾 Simple session management for Neovim
https://github.com/folke/persistence.nvim
neovim neovim-plugin
Last synced: 11 days ago
JSON representation
💾 Simple session management for Neovim
- Host: GitHub
- URL: https://github.com/folke/persistence.nvim
- Owner: folke
- License: apache-2.0
- Created: 2021-07-02T06:54:30.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-12T03:54:08.000Z (16 days ago)
- Last Synced: 2024-06-12T10:24:55.697Z (15 days ago)
- Topics: neovim, neovim-plugin
- Language: Lua
- Homepage:
- Size: 64.5 KB
- Stars: 558
- Watchers: 7
- Forks: 25
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Lists
- awesome-stars - persistence.nvim
- awesome-stars - folke/persistence.nvim - 💾 Simple session management for Neovim (Lua)
- awesome-stars - folke/persistence.nvim - 💾 Simple session management for Neovim (Lua)
- awesome-stars - folke/persistence.nvim - 💾 Simple session management for Neovim (Lua)
README
# 💾 Persistence
**Persistence** is a simple lua plugin for automated session management.
## ✨ Features
- automatically saves the active session under `~/.local/state/nvim/sessions` on exit
- simple API to restore the current or last session## ⚡️ Requirements
- Neovim >= 0.7.2
## 📦 Installation
Install the plugin with your preferred package manager:
### [lazy.nvim](https://github.com/folke/lazy.nvim)
```lua
-- Lua
{
"folke/persistence.nvim",
event = "BufReadPre", -- this will only start session saving when an actual file was opened
opts = {
-- add any custom options here
}
}
```## ⚙️ Configuration
Persistence comes with the following defaults:
```lua
{
dir = vim.fn.stdpath("state") .. "/sessions/", -- directory where session files are saved
options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
pre_save = nil, -- a function to call before saving the session
post_save = nil, -- a function to call after saving the session
save_empty = false, -- don't save if there are no open file buffers
pre_load = nil, -- a function to call before loading the session
post_load = nil, -- a function to call after loading the session
}
```## 🚀 Usage
**Persistence** works well with plugins like `startify` or `dashboard`. It will never restore a session automatically,
but you can of course write an autocmd that does exactly that if you want.```lua
-- restore the session for the current directory
vim.api.nvim_set_keymap("n", "qs", [[lua require("persistence").load()]], {})-- restore the last session
vim.api.nvim_set_keymap("n", "ql", [[lua require("persistence").load({ last = true })]], {})-- stop Persistence => session won't be saved on exit
vim.api.nvim_set_keymap("n", "qd", [[lua require("persistence").stop()]], {})
```