diff options
| author | nsfisis <nsfisis@gmail.com> | 2021-11-27 22:36:31 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2021-11-27 22:38:54 +0900 |
| commit | 74b4e5aac83250759a6246216c2c361bab653a5b (patch) | |
| tree | efacb5bd25b228935f757587df9ef8ed07477c0a /.config/nvim/autoload/autosave.vim | |
| parent | 4a5ce361a1f435ae6e9b7cacb1e70a9da1bb80e2 (diff) | |
| download | dotfiles-74b4e5aac83250759a6246216c2c361bab653a5b.tar.gz dotfiles-74b4e5aac83250759a6246216c2c361bab653a5b.tar.zst dotfiles-74b4e5aac83250759a6246216c2c361bab653a5b.zip | |
neovim: move my plugin directories
Diffstat (limited to '.config/nvim/autoload/autosave.vim')
| -rw-r--r-- | .config/nvim/autoload/autosave.vim | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/.config/nvim/autoload/autosave.vim b/.config/nvim/autoload/autosave.vim new file mode 100644 index 0000000..be64707 --- /dev/null +++ b/.config/nvim/autoload/autosave.vim @@ -0,0 +1,64 @@ +scriptencoding utf-8 + + + +if !exists('g:autosave_interval_ms') + let g:autosave_interval_ms = 10 * 1000 +endif + +if !exists('g:autosave_silent') + let g:autosave_silent = v:true +endif + + + +function! autosave#handler(timer_id) abort + if !&modified + return + endif + if &readonly + return + endif + if &buftype !=# '' + return + endif + if expand('%') ==# '' + return + endif + + if !g:autosave_silent + echohl Comment + echo 'Auto-saving...' + echohl None + endif + + silent! write + + if !g:autosave_silent + echohl Comment + echo 'Saved.' + echohl None + endif +endfunction + + +function! autosave#enable() abort + if exists('b:autosave_timer') + return + endif + + let b:autosave_timer = timer_start( + \ g:autosave_interval_ms, + \ 'autosave#handler', + \ { 'repeat': -1 }) +endfunction + + +function! autosave#disable() abort + if !exists('b:autosave_timer') + return + endif + + call timer_stop('b:autosave_timer') + unlet b:autosave_timer +endfunction |
