Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
adcf691369 | |||
5e47847262 | |||
f4bb0c5641 | |||
d8a3eda0e1 | |||
b0e2b283c6 | |||
cc68aed5a1 | |||
5b7e71abe9 | |||
8484fdaa28 | |||
8c40aa7b80 | |||
70c281e54e | |||
7421e30704 | |||
5453a25028 |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -55,7 +55,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
release-type: simple
|
release-type: simple
|
||||||
package-name: persistence.nvim
|
package-name: persistence.nvim
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: tag stable versions
|
- name: tag stable versions
|
||||||
if: ${{ steps.release.outputs.release_created }}
|
if: ${{ steps.release.outputs.release_created }}
|
||||||
run: |
|
run: |
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,3 +4,5 @@ doc/tags
|
|||||||
debug
|
debug
|
||||||
.repro
|
.repro
|
||||||
foo.*
|
foo.*
|
||||||
|
*.log
|
||||||
|
data
|
||||||
|
14
CHANGELOG.md
14
CHANGELOG.md
@ -1,5 +1,19 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.1.0](https://github.com/folke/persistence.nvim/compare/v1.0.1...v1.1.0) (2023-02-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **persistence:** `pre_save` option to call before saving ([#22](https://github.com/folke/persistence.nvim/issues/22)) ([f4bb0c5](https://github.com/folke/persistence.nvim/commit/f4bb0c5641a0e6c9ac3675ddd794ca78099d8510))
|
||||||
|
|
||||||
|
## [1.0.1](https://github.com/folke/persistence.nvim/compare/v1.0.0...v1.0.1) (2023-01-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* dont throw error when session was already stopped ([70c281e](https://github.com/folke/persistence.nvim/commit/70c281e54e34630d8bef9b1cf9f7a0ac3edd6a1c))
|
||||||
|
|
||||||
## 1.0.0 (2023-01-04)
|
## 1.0.0 (2023-01-04)
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
## ✨ Features
|
## ✨ Features
|
||||||
|
|
||||||
- automatically saves the active session under `.config/nvim/sessions` on exit
|
- automatically saves the active session under `~/.local/state/nvim/sessions` on exit
|
||||||
- simple API to restore the current or last session
|
- simple API to restore the current or last session
|
||||||
|
|
||||||
## ⚡️ Requirements
|
## ⚡️ Requirements
|
||||||
|
|
||||||
- Neovim >= 0.5.0
|
- Neovim >= 0.7.2
|
||||||
|
|
||||||
## 📦 Installation
|
## 📦 Installation
|
||||||
|
|
||||||
@ -50,8 +50,9 @@ Persistence comes with the following defaults:
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
dir = vim.fn.expand(vim.fn.stdpath("config") .. "/sessions/"), -- directory where session files are saved
|
dir = vim.fn.expand(vim.fn.stdpath("state") .. "/sessions/"), -- directory where session files are saved
|
||||||
options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
|
options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
|
||||||
|
pre_save = nil, -- a function to call before saving the session
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1,38 +1,40 @@
|
|||||||
*persistence.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 04
|
*persistence.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 28
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
Table of Contents *persistence.nvim-table-of-contents*
|
Table of Contents *persistence.nvim-table-of-contents*
|
||||||
|
|
||||||
1. Persistence |persistence.nvim-persistence|
|
1. Persistence |persistence.nvim-persistence|
|
||||||
- Features |persistence.nvim-features|
|
- Features |persistence.nvim-persistence-features|
|
||||||
- Requirements |persistence.nvim-requirements|
|
- Requirements |persistence.nvim-persistence-requirements|
|
||||||
- Installation |persistence.nvim-installation|
|
- Installation |persistence.nvim-persistence-installation|
|
||||||
- Configuration |persistence.nvim-configuration|
|
- Configuration |persistence.nvim-persistence-configuration|
|
||||||
- Usage |persistence.nvim-usage|
|
- Usage |persistence.nvim-persistence-usage|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
1. Persistence *persistence.nvim-persistence*
|
1. Persistence *persistence.nvim-persistence*
|
||||||
|
|
||||||
**Persistence** is a simple lua plugin for automated session management.
|
**Persistence** is a simple lua plugin for automated session management.
|
||||||
|
|
||||||
FEATURES *persistence.nvim-features*
|
|
||||||
|
FEATURES *persistence.nvim-persistence-features*
|
||||||
|
|
||||||
|
|
||||||
- automatically saves the active session under `.config/nvim/sessions` on exit
|
- automatically saves the active session under `~/.local/state/nvim/sessions` on exit
|
||||||
- simple API to restore the current or last session
|
- simple API to restore the current or last session
|
||||||
|
|
||||||
|
|
||||||
REQUIREMENTS *persistence.nvim-requirements*
|
REQUIREMENTS *persistence.nvim-persistence-requirements*
|
||||||
|
|
||||||
|
|
||||||
- Neovim >= 0.5.0
|
- Neovim >= 0.7.2
|
||||||
|
|
||||||
|
|
||||||
INSTALLATION *persistence.nvim-installation*
|
INSTALLATION *persistence.nvim-persistence-installation*
|
||||||
|
|
||||||
Install the plugin with your preferred package manager:
|
Install the plugin with your preferred package manager:
|
||||||
|
|
||||||
PACKER <HTTPS://GITHUB.COM/WBTHOMASON/PACKER.NVIM> ~
|
|
||||||
|
PACKER ~
|
||||||
|
|
||||||
>lua
|
>lua
|
||||||
-- Lua
|
-- Lua
|
||||||
@ -47,7 +49,7 @@ PACKER <HTTPS://GITHUB.COM/WBTHOMASON/PACKER.NVIM> ~
|
|||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
VIM-PLUG <HTTPS://GITHUB.COM/JUNEGUNN/VIM-PLUG> ~
|
VIM-PLUG ~
|
||||||
|
|
||||||
>vim
|
>vim
|
||||||
" Vim Script
|
" Vim Script
|
||||||
@ -63,19 +65,20 @@ VIM-PLUG <HTTPS://GITHUB.COM/JUNEGUNN/VIM-PLUG> ~
|
|||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
CONFIGURATION *persistence.nvim-configuration*
|
CONFIGURATION *persistence.nvim-persistence-configuration*
|
||||||
|
|
||||||
Persistence comes with the following defaults:
|
Persistence comes with the following defaults:
|
||||||
|
|
||||||
>lua
|
>lua
|
||||||
{
|
{
|
||||||
dir = vim.fn.expand(vim.fn.stdpath("config") .. "/sessions/"), -- directory where session files are saved
|
dir = vim.fn.expand(vim.fn.stdpath("state") .. "/sessions/"), -- directory where session files are saved
|
||||||
options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
|
options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
|
||||||
|
pre_save = nil, -- a function to call before saving the session
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
USAGE *persistence.nvim-usage*
|
USAGE *persistence.nvim-persistence-usage*
|
||||||
|
|
||||||
**Persistence** works well with plugins like `startify` or `dashboard`. It will
|
**Persistence** works well with plugins like `startify` or `dashboard`. It will
|
||||||
never restore a session automatically, but you can of course write an autocmd
|
never restore a session automatically, but you can of course write an autocmd
|
||||||
@ -92,7 +95,6 @@ that does exactly that if you want.
|
|||||||
vim.api.nvim_set_keymap("n", "<leader>qd", [[<cmd>lua require("persistence").stop()<cr>]], {})
|
vim.api.nvim_set_keymap("n", "<leader>qd", [[<cmd>lua require("persistence").stop()<cr>]], {})
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
|
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
|
||||||
|
|
||||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
@ -69,8 +69,9 @@ Persistence comes with the following defaults:
|
|||||||
|
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
dir = vim.fn.expand(vim.fn.stdpath("config") .. "/sessions/"), -- directory where session files are saved
|
dir = vim.fn.expand(vim.fn.stdpath("state") .. "/sessions/"), -- directory where session files are saved
|
||||||
options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
|
options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
|
||||||
|
pre_save = nil, -- a function to call before saving the session
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
---@class PersistenceOptions
|
---@class PersistenceOptions
|
||||||
|
---@field pre_save? fun()
|
||||||
local defaults = {
|
local defaults = {
|
||||||
dir = vim.fn.expand(vim.fn.stdpath("state") .. "/sessions/"), -- directory where session files are saved
|
dir = vim.fn.expand(vim.fn.stdpath("state") .. "/sessions/"), -- directory where session files are saved
|
||||||
options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
|
options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
|
||||||
|
@ -27,19 +27,20 @@ function M.setup(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.start()
|
function M.start()
|
||||||
vim.cmd([[
|
vim.api.nvim_create_autocmd("VimLeavePre", {
|
||||||
augroup Persistence
|
group = vim.api.nvim_create_augroup("persistence", { clear = true }),
|
||||||
autocmd!
|
callback = function()
|
||||||
autocmd VimLeavePre * lua require("persistence").save()
|
if Config.options.pre_save then
|
||||||
augroup end
|
Config.options.pre_save()
|
||||||
]])
|
end
|
||||||
|
|
||||||
|
M.save()
|
||||||
|
end,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.stop()
|
function M.stop()
|
||||||
vim.cmd([[
|
pcall(vim.api.nvim_del_augroup_by_name, "persistence")
|
||||||
autocmd! Persistence
|
|
||||||
augroup! Persistence
|
|
||||||
]])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.save()
|
function M.save()
|
||||||
|
Reference in New Issue
Block a user