Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure refresh speed #10

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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