Merge pull request #9 from refractalize/better-events-default

Better events default
This commit is contained in:
Pocco81
2021-07-18 19:22:47 -05:00
committed by GitHub
4 changed files with 18 additions and 20 deletions
+1 -1
View File
@@ -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 = {},
+11 -13
View File
@@ -4,7 +4,7 @@ local cmd = vim.cmd
local opts = require("autosave.config").options
local autosave = require("autosave")
local default_event = "InsertLeave"
local default_events = {"InsertLeave", "TextChanged"}
local modified
@@ -142,18 +142,16 @@ function M.save()
end
end
local function events()
if (next(opts["events"]) == nil or opts["events"] == nil) then
return default_events
else
return opts["events"]
end
end
local function parse_events()
local events = ""
if (next(opts["events"]) == nil or opts["events"] == nil) then
events = default_event
else
for event, _ in pairs(opts["events"]) do
events = events .. opts["events"][event] .. ","
end
end
return events
return table.concat(events(), ",")
end
function M.load_autocommands()
@@ -176,7 +174,7 @@ function M.load_autocommands()
false
)
else
local event_1 = opts["events"][1] or default_event
local event_1 = events()[1]
api.nvim_exec(
[[
aug autosave_save