You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently upgraded to the new version and setup the config as:
Is there a way to have utils.in(fn.getbufvar(buf, "&filetype"), {'md', 'tex', 'org', 'txt'}) as in:
localautosave=require("auto-save")
autosave.setup({
enabled=true,
execution_message="AutoSave: saved at " ..vim.fn.strftime("%H:%M:%S"),
events= {"InsertLeave", "TextChanged"},
-- function that determines whether to save the current buffer or not-- return true: if buffer is ok to be saved-- return false: if it's not ok to be savedcondition=function(buf)
localfn=vim.fnlocalutils=require("auto-save.utils.data")
iffn.getbufvar(buf, "&modifiable") ==1andutils.in(fn.getbufvar(buf, "&filetype"), {'md', 'tex', 'org', 'txt'}) thenreturntrue-- met condition(s), can saveendreturnfalse-- can't saveend,
write_all_buffers=false,
debounce_delay=135
})
Where I only want to save for 'md' 'tex' etc.
I am not well versed in lua and thus am having difficulty with checking whether the buf type is in the provided list of allowed filetypes.
The text was updated successfully, but these errors were encountered:
AFAIK there's no built in way in Lua to check if element exists in a table. While there's no explicit in method in utils either you can use the set_of method there to do exactly that:
condition=function(buf)
localfn=vim.fnlocalutils=require("auto-save.utils.data")
iffn.getbufvar(buf, "&modifiable") ==1andutils.set_of({'md', 'tex', 'org', 'txt'})[fn.getbufvar(buf, "&filetype")]
thenreturntrue-- met condition(s), can saveendreturnfalse-- can't saveend,
I recently upgraded to the new version and setup the config as:
Is there a way to have
utils.in(fn.getbufvar(buf, "&filetype"), {'md', 'tex', 'org', 'txt'})
as in:Where I only want to save for 'md' 'tex' etc.
I am not well versed in lua and thus am having difficulty with checking whether the buf type is in the provided list of allowed filetypes.
The text was updated successfully, but these errors were encountered: