Skip to content

Commit

Permalink
Merge pull request #10 from tuurep/configure-refresh-speed
Browse files Browse the repository at this point in the history
Configure refresh speed
  • Loading branch information
jannis-baum authored Jul 25, 2024
2 parents 90dd373 + d2cea5e commit c2d085b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions plugin/vivify.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit c2d085b

Please sign in to comment.