From 9beebb5b4d804c4ea758443f361a03b757eb662f Mon Sep 17 00:00:00 2001 From: kdav5758 Date: Thu, 1 Jul 2021 17:38:58 -0500 Subject: [PATCH] fixed logic and cleaned code --- lua/autosave/modules/autocmds.lua | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lua/autosave/modules/autocmds.lua b/lua/autosave/modules/autocmds.lua index ba93f4a..f0232c4 100644 --- a/lua/autosave/modules/autocmds.lua +++ b/lua/autosave/modules/autocmds.lua @@ -7,7 +7,7 @@ local cmd = vim.cmd local M = {} local function table_has_value(tbl, value) - for key, value in pairs(tbl) do + for key, _ in pairs(tbl) do if (tbl[key] == value) then return true end @@ -24,7 +24,7 @@ local function get_modified() return modified end -local function do_save() +function M.do_save() if (opts["save_only_if_exists"] == true) then if (fn.filereadable(fn.expand("%:p")) == 1) then if not (next(opts["excluded_filetypes"]) == nil) then @@ -45,7 +45,7 @@ function M.save() if (opts["write_all_buffers"] == true) then cmd([[call g:AutoSaveBufDo("lua require'autosave.modules.autocmds'.do_save()")]]) else - do_save() + M.do_save() end if (opts["execution_message"] ~= "" and get_modified() == true) then @@ -60,7 +60,6 @@ local function parse_events() events = "InsertLeave" else for event, _ in pairs(opts["events"]) do - print("event 1 = ".. event .. "; event 2 " == opts["events"][event]) events = events .. opts["events"][event] .. "," end end @@ -70,8 +69,6 @@ end function M.load_autocommands() - print("Parsed events = " .. tostring(parse_events())) - api.nvim_exec( [[ augroup autosave_save