From db206fda286c79c0936ecb0b6f642579abccb54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20M=C3=BCller?= Date: Fri, 21 Jul 2023 08:32:46 +0200 Subject: [PATCH] fix: [#30] Don't turn autosave on before reading user config (#32) --- lua/auto-save/init.lua | 10 +++++++++- plugin/auto-save.lua | 10 ---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lua/auto-save/init.lua b/lua/auto-save/init.lua index 032b002..2e4eef2 100644 --- a/lua/auto-save/init.lua +++ b/lua/auto-save/init.lua @@ -12,7 +12,7 @@ local cmd = vim.cmd local schedule = vim.schedule local logger -local autosave_running +local autosave_running = nil autocmds.create_augroup({ clear = true }) @@ -183,6 +183,14 @@ end function M.setup(custom_opts) cnf:set_options(custom_opts) logger = require("auto-save.utils.logging").new(cnf:get_options()) + + if autosave_running == nil then + if cnf.opts.enabled then + M.on() + else + M.off() + end + end end return M diff --git a/plugin/auto-save.lua b/plugin/auto-save.lua index 003d8ae..65e7d85 100644 --- a/plugin/auto-save.lua +++ b/plugin/auto-save.lua @@ -1,15 +1,5 @@ -if vim.g.loaded_auto_save then - return -end -vim.g.loaded_auto_save = true - local command = vim.api.nvim_create_user_command -local cnf = require("auto-save.config").opts command("ASToggle", function() require("auto-save").toggle() end, {}) - -if cnf.enabled then - require("auto-save").on() -end