mirror of
https://github.com/zoriya/auto-save.nvim.git
synced 2026-06-08 04:31:06 +00:00
moved modifiable condition to autocmd
This commit is contained in:
@@ -38,7 +38,7 @@ end
|
|||||||
function M.do_save()
|
function M.do_save()
|
||||||
|
|
||||||
-- cs = can save
|
-- cs = can save
|
||||||
local cs_exists, cs_filetype, cs_modifiable = true, true, true
|
local cs_exists, cs_filetype = true, true
|
||||||
|
|
||||||
if not (next(opts["excluded_filetypes"]) == nil) then
|
if not (next(opts["excluded_filetypes"]) == nil) then
|
||||||
if (table_has_value(opts["excluded_filetypes"], api.nvim_eval([[&filetype]])) == true) then
|
if (table_has_value(opts["excluded_filetypes"], api.nvim_eval([[&filetype]])) == true) then
|
||||||
@@ -52,11 +52,7 @@ function M.do_save()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (api.nvim_eval([[&modifiable]]) == 0) then
|
if (cs_exists == true and cs_filetype == true) then
|
||||||
cs_modifiable = false
|
|
||||||
end
|
|
||||||
|
|
||||||
if (cs_exists == true and cs_filetype == true and cs_modifiable == true) then
|
|
||||||
actual_save()
|
actual_save()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -100,7 +96,7 @@ function M.load_autocommands()
|
|||||||
augroup autosave_save
|
augroup autosave_save
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd ]] ..
|
autocmd ]] ..
|
||||||
parse_events() .. [[ * execute "lua require'autosave.modules.autocmds'.save()"
|
parse_events() .. [[ * if (&modifiable == 1) | execute "lua require'autosave.modules.autocmds'.save()" | endif
|
||||||
augroup END
|
augroup END
|
||||||
]],
|
]],
|
||||||
false
|
false
|
||||||
|
|||||||
Reference in New Issue
Block a user