-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Hey, I've identified that one of my most common habits of opening a viewer is reading a markdown document far down somewhere, and wanting to preview that same section.
But the way it's currently set up is that it opens at top, and I have focus back to (n)vim and do a jk
or something.
Of course at first I thought it'd be as simple as doing call vivify#sync_cursor()
after first opening viv like so:
function! vivify#open()
" Note: nvim's jobstart doesn't use these opt keys
call s:job_start(
\ ['viv', expand('%:p')],
\ {"in_io": "null", "out_io": "null", "err_io": "null"}
\)
call vivify#sync_cursor()
endfunction
However then it tries syncing cursor before the webpage has finished loading (I believe?)
Putting a 1 second sleep before sync_cursor works:
function! vivify#open()
" Note: nvim's jobstart doesn't use these opt keys
call s:job_start(
\ ['viv', expand('%:p')],
\ {"in_io": "null", "out_io": "null", "err_io": "null"}
\)
exec 'sleep'
call vivify#sync_cursor()
endfunction
So...
Do you know of an easy way to do the sync_cursor at the exact time the webpage has finished loading?
Maybe I could find something in how Vim's job control works. Thought I'd ask if this is something you know off the top of your head.
Also, agree it's something that should be added?