mirror of
https://github.com/folke/persistence.nvim.git
synced 2025-07-03 05:54:48 +02:00
fix: dont throw error when session was already stopped
This commit is contained in:
parent
7421e30704
commit
70c281e54e
3 changed files with 10 additions and 11 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,3 +4,5 @@ doc/tags
|
||||||
debug
|
debug
|
||||||
.repro
|
.repro
|
||||||
foo.*
|
foo.*
|
||||||
|
*.log
|
||||||
|
data
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
## ⚡️ Requirements
|
## ⚡️ Requirements
|
||||||
|
|
||||||
- Neovim >= 0.5.0
|
- Neovim >= 0.7.2
|
||||||
|
|
||||||
## 📦 Installation
|
## 📦 Installation
|
||||||
|
|
||||||
|
|
|
@ -27,19 +27,16 @@ 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()
|
M.save()
|
||||||
augroup end
|
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()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue