mirror of
https://github.com/zoriya/auto-save.nvim.git
synced 2026-08-15 02:13:22 +00:00
fixed do_save()
This commit is contained in:
@@ -24,23 +24,32 @@ local function get_modified()
|
||||
return modified
|
||||
end
|
||||
|
||||
local function actual_save()
|
||||
-- might use update, but in that case it can't be checekd if a file was modified and so it will always
|
||||
-- print opts["execution_message"]
|
||||
if (api.nvim_eval([[&modified]]) == 1) then
|
||||
print("here 4")
|
||||
cmd("write")
|
||||
if (get_modified() == nil) then
|
||||
set_modified(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.do_save()
|
||||
if (opts["save_only_if_exists"] == true) then
|
||||
print("here 1")
|
||||
print("here 1")
|
||||
if (fn.filereadable(fn.expand("%:p")) == 1) then
|
||||
print("here 2")
|
||||
print("here 2")
|
||||
if not (next(opts["excluded_filetypes"]) == nil) then
|
||||
print("here 3")
|
||||
print("here 3")
|
||||
if (table_has_value(opts["excluded_filetypes"], api.nvim_eval([[&filetype]])) == false) then
|
||||
print("here 3")
|
||||
-- might use update, but in that case it can't be checekd if a file was modified and so it will always
|
||||
-- print opts["execution_message"]
|
||||
if (api.nvim_eval([[&modified]]) == 1) then
|
||||
print("here 4")
|
||||
cmd("write")
|
||||
if (get_modified() == nil) then set_modified(true) end
|
||||
end
|
||||
print("here 4")
|
||||
actual_save()
|
||||
end
|
||||
else
|
||||
print("here 5")
|
||||
actual_save()
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -73,7 +82,6 @@ local function parse_events()
|
||||
end
|
||||
|
||||
function M.load_autocommands()
|
||||
|
||||
api.nvim_exec(
|
||||
[[
|
||||
augroup autosave_save
|
||||
|
||||
Reference in New Issue
Block a user