From b175066b66dc69f5c6e6386eb4e429433a77f734 Mon Sep 17 00:00:00 2001 From: Tim Macfarlane Date: Sun, 18 Jul 2021 19:38:10 +0200 Subject: [PATCH] Add TextChanged to default_events. --- lua/autosave/modules/autocmds.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lua/autosave/modules/autocmds.lua b/lua/autosave/modules/autocmds.lua index 72c239d..a22c9cf 100644 --- a/lua/autosave/modules/autocmds.lua +++ b/lua/autosave/modules/autocmds.lua @@ -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 M = {} @@ -112,12 +112,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() - if (next(opts["events"]) == nil or opts["events"] == nil) then - return default_event - else - return table.concat(opts["events"], ",") - end + return table.concat(events(), ",") end function M.load_autocommands() @@ -134,7 +138,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