diff --git a/README.md b/README.md index 845be4f..9c413f5 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ As it's stated in the TL;DR, there are already some sane defaults that you may l ```lua enabled = true, execution_message = "AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"), -events = {"InsertLeave"}, +events = {"InsertLeave", "TextChanged"}, conditions = { exists = true, filetype_is_not = {}, @@ -146,7 +146,7 @@ autosave.setup( { enabled = true, execution_message = "AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"), - events = {"InsertLeave"}, + events = {"InsertLeave", "TextChanged"}, conditions = { exists = true, filetype_is_not = {}, @@ -174,7 +174,7 @@ autosave.setup( { enabled = true, execution_message = "AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"), - events = {"InsertLeave"}, + events = {"InsertLeave", "TextChanged"}, conditions = { exists = true, filetype_is_not = {}, diff --git a/doc/autosave.txt b/doc/autosave.txt index bfd38cf..d5542fc 100644 --- a/doc/autosave.txt +++ b/doc/autosave.txt @@ -63,7 +63,7 @@ As it's stated in the TL;DR, there are already some sane defaults that you may l ```lua enabled = true, execution_message = "AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"), -events = {"InsertLeave"}, +events = {"InsertLeave", "TextChanged"}, conditions = { exists = true, filetype_is_not = {}, @@ -85,7 +85,7 @@ autosave.setup( { enabled = true, execution_message = "AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"), - events = {"InsertLeave"}, + events = {"InsertLeave", "TextChanged"}, conditions = { exists = true, filetype_is_not = {}, @@ -108,7 +108,7 @@ autosave.setup( { enabled = true, execution_message = "AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"), - events = {"InsertLeave"}, + events = {"InsertLeave", "TextChanged"}, conditions = { exists = true, filetype_is_not = {}, diff --git a/lua/autosave/config.lua b/lua/autosave/config.lua index 2a18283..78f6002 100644 --- a/lua/autosave/config.lua +++ b/lua/autosave/config.lua @@ -3,7 +3,7 @@ local config = {} config.options = { enabled = true, execution_message = "AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"), - events = {"InsertLeave"}, + events = {"InsertLeave", "TextChanged"}, conditions = { exists = true, filetype_is_not = {}, diff --git a/lua/autosave/modules/autocmds.lua b/lua/autosave/modules/autocmds.lua index 89bcaba..72c239d 100644 --- a/lua/autosave/modules/autocmds.lua +++ b/lua/autosave/modules/autocmds.lua @@ -113,17 +113,11 @@ function M.save() end local function parse_events() - local events = "" - if (next(opts["events"]) == nil or opts["events"] == nil) then - events = default_event + return default_event else - for event, _ in pairs(opts["events"]) do - events = events .. opts["events"][event] .. "," - end + return table.concat(opts["events"], ",") end - - return events end function M.load_autocommands()