mirror of
https://github.com/zoriya/auto-save.nvim.git
synced 2026-08-16 02:44:35 +00:00
simplified setup()
This commit is contained in:
+1
-12
@@ -14,19 +14,8 @@ function config.set_options(opts)
|
|||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
for opt, _ in pairs(opts) do
|
for opt, _ in pairs(opts) do
|
||||||
-- check if option exists in the config's table
|
|
||||||
if (config.options[opt] ~= nil) then -- not nil
|
if (config.options[opt] ~= nil) then -- not nil
|
||||||
-- chec if option is a table
|
config.options[opt] = opts[opt]
|
||||||
if (type(opts[opt]) == "table") then -- if table
|
|
||||||
for inner_opt, _ in pairs(opts[opt]) do
|
|
||||||
-- table contains element by that key
|
|
||||||
if (config.options[opt][inner_opt] ~= nil) then -- not nil
|
|
||||||
config.options[opt][inner_opt] = opts[opt][inner_opt]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
config.options[opt] = opts[opt]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ local function setup_commands()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.setup(custom_opts)
|
function M.setup(custom_opts)
|
||||||
|
print("Setting up the plugin...")
|
||||||
require("autosave.config").set_options(custom_opts)
|
require("autosave.config").set_options(custom_opts)
|
||||||
setup_commands()
|
setup_commands()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ local function parse_events()
|
|||||||
events = "InsertLeave"
|
events = "InsertLeave"
|
||||||
else
|
else
|
||||||
for event, _ in pairs(opts["events"]) do
|
for event, _ in pairs(opts["events"]) do
|
||||||
|
print("event 1 = ".. event .. "; event 2 " == opts["events"][event])
|
||||||
events = events .. opts["events"][event] .. ","
|
events = events .. opts["events"][event] .. ","
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user