diff --git a/.gitignore b/.gitignore index e62ab00..cc5457a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ doc/tags debug .repro foo.* +*.log +data diff --git a/README.md b/README.md index c7e7101..9ac32e6 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ## ⚡️ Requirements -- Neovim >= 0.5.0 +- Neovim >= 0.7.2 ## 📦 Installation diff --git a/lua/persistence/init.lua b/lua/persistence/init.lua index 4c3fb32..2398f66 100644 --- a/lua/persistence/init.lua +++ b/lua/persistence/init.lua @@ -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()