fix: dont throw error when session was already stopped

This commit is contained in:
Folke Lemaitre 2023-01-06 19:28:37 +01:00
parent 7421e30704
commit 70c281e54e
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
3 changed files with 10 additions and 11 deletions

2
.gitignore vendored
View File

@ -4,3 +4,5 @@ doc/tags
debug
.repro
foo.*
*.log
data

View File

@ -9,7 +9,7 @@
## ⚡️ Requirements
- Neovim >= 0.5.0
- Neovim >= 0.7.2
## 📦 Installation

View File

@ -27,19 +27,16 @@ function M.setup(opts)
end
function M.start()
vim.cmd([[
augroup Persistence
autocmd!
autocmd VimLeavePre * lua require("persistence").save()
augroup end
]])
vim.api.nvim_create_autocmd("VimLeavePre", {
group = vim.api.nvim_create_augroup("persistence", { clear = true }),
callback = function()
M.save()
end,
})
end
function M.stop()
vim.cmd([[
autocmd! Persistence
augroup! Persistence
]])
pcall(vim.api.nvim_del_augroup_by_name, "persistence")
end
function M.save()