diff --git a/README.md b/README.md index 13b0ed3..1fe5431 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,16 @@ NeoVim is supported. - all open viewers automatically scroll to keep in sync with your cursor in Vim - open the current buffer's contents in vivify with `:Vivify` +## Configuration + +- `g:vivify_instant_refresh = 1` + - refresh page contents on `TextChanged` and `TextChangedI` (default) +- `g:vivify_instant_refresh = 0` + - refresh page contents on `CursorHold` and `CursorHoldI` +- `g:vivify_filetypes` + - additional filetypes to recognize as markdown + - for example `let g:vivify_filetypes = ['vimwiki']` + ## Installation With [vivify](https://github.com/jannis-baum/vivify) installed in your PATH, you diff --git a/plugin/vivify.vim b/plugin/vivify.vim index fc15c0d..2af0e1a 100644 --- a/plugin/vivify.vim +++ b/plugin/vivify.vim @@ -3,6 +3,8 @@ if exists("g:loaded_vivify") endif let g:loaded_vivify = 1 +let s:vivify_instant_refresh = get(g:, "vivify_instant_refresh", 1) + let s:filetype_match_str = 'markdown' if exists("g:vivify_filetypes") call add(g:vivify_filetypes, s:filetype_match_str) @@ -16,8 +18,13 @@ endfunction function! s:init() augroup vivify_sync autocmd! - autocmd CursorHold,CursorHoldI * - \ if s:is_vivify_filetype(&filetype) | call vivify#sync_content() | endif + if s:vivify_instant_refresh + autocmd TextChanged,TextChangedI * + \ if s:is_vivify_filetype(&filetype) | call vivify#sync_content() | endif + else + autocmd CursorHold,CursorHoldI * + \ if s:is_vivify_filetype(&filetype) | call vivify#sync_content() | endif + endif autocmd CursorMoved,CursorMovedI * \ if s:is_vivify_filetype(&filetype) | call vivify#sync_cursor() | endif augroup END