I tried using windo set scrollbind, but this doesn't work on a popup window (as far as i know).
It cannot work because :windo
only works on windows which have a number; popup windows don't.
Any ways to do this?
OTOH, popup windows do have an ID. So, you could try:
call win_execute(winid, 'setlocal scrollbind')
Or:
call setwinvar(winid, '&scrollbind', 1)
But it won't give you the desired result.
In case you're interested in an alternative solution, try this:
vim9script
com -bang -bar CustomColumnNumber CustomColumnNumber(<bang>0)
def CustomColumnNumber(off: bool)
if off
if exists('w:_ccn_winid')
popup_close(w:_ccn_winid)
unlet! w:_ccn_winid w:_ccn_lastlnum
au! scroll_custom_numbercolumn
endif
return
elseif exists('w:_ccn_winid')
return
endif
var what = range(1, line('$'))->map({_, i -> string(i)})
w:_ccn_winid = popup_create(what, #{
line: 1,
col: 1,
minwidth: 1,
minheight: 1,
maxheight: &lines - 1,
wrap: 0,
mapping: 0,
firstline: 1,
})
augroup scroll_custom_numbercolumn
au! * <buffer>
au CursorMoved <buffer> Scroll_custom_column_number()
augroup END
enddef
def Scroll_custom_column_number()
var curlnum = line('.')
if curlnum == get(w:, '_ccn_lastlnum') || !exists('w:_ccn_winid')
return
endif
w:_ccn_lastlnum = curlnum
popup_setoptions(w:_ccn_winid, #{firstline: line('w0')})
enddef
Write the code in ~/.vim/plugin/mycustomcolumnnumber.vim
. It works on 8.2.1788.
It should install the custom command :CustomColumnNumber
which should display a popup window with numbers matching the line addresses; and it should scroll when you move in the buffer. Add a bang to toggle the popup off: :CustomColumnNumber!
.
I only tested the code briefly, so there might be bugs to fix, and you might want to tweak the code to change the appearance of the popup.