repos/autosave.vim

vim plugin to autosave buffer when leaving cursor idle
Commits Files Refs README LICENSE
commit be79f9d61f2b3219f2c5ccc14267242e81afd845
parent d5674172e1c0963ed2be0705aa7969f6ca0bab82
Author: mjkloeckner <martin.cachari@gmail.com>
Date:   Sun, 30 Apr 2023 17:21:31 -0300

fix autosave only working for the first opened file

Diffstat:
Mplugin/autosave.vim | 15+++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/plugin/autosave.vim b/plugin/autosave.vim
@@ -25,8 +25,15 @@ function s:auto_save()
     endif
 endfunction
 
-au TextChanged,TextChangedI <buffer> silent! let s:auto_save_write = 1
-au CursorHold,CursorHoldI <buffer> call s:auto_save()
+function s:autosave_current_buffer_enable()
+    let s:auto_save_filetype_enabled = 1
+    au TextChanged,TextChangedI <buffer> silent! let s:auto_save_write = 1
+    au CursorHold,CursorHoldI <buffer> call s:auto_save()
+endfunction
 
-au BufEnter,FileType * if index(g:auto_save_filetypes, &filetype) !=# -1 |
-            \ let s:auto_save_filetype_enabled = 1 | endif
+if g:auto_save_all_filetypes == 0
+    au BufEnter,FileType * if index(g:auto_save_filetypes, &filetype) !=# -1 |
+                \ call s:autosave_current_buffer_enable() | endif
+else
+    au BufEnter,FileType * call s:autosave_current_buffer_enable()
+endif