-
Notifications
You must be signed in to change notification settings - Fork 10
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
Option to only show on mouse scroll? #3
Comments
Yes. autocmd CursorHold * silent! lua require('scrollbar').clear() |
I had problems getting this working and was able to boil it down to the configuration below. It seems that vim-airline-clock (together with vim-airline) is the problem. For some reason the scrollbar never goes away on call plug#begin('~/.vim/bundle')
Plug 'bling/vim-airline'
Plug 'enricobacis/vim-airline-clock'
Plug 'Xuyuanp/scrollbar.nvim'
call plug#end()
augroup scrollbar
autocmd!
autocmd BufEnter * silent! lua require('scrollbar').show()
autocmd BufLeave * silent! lua require('scrollbar').clear()
autocmd CursorMoved * silent! lua require('scrollbar').show()
autocmd VimResized * silent! lua require('scrollbar').show()
autocmd FocusGained * silent! lua require('scrollbar').show()
autocmd FocusLost * silent! lua require('scrollbar').clear()
autocmd CursorHold * silent! lua require('scrollbar').clear()
augroup end
set updatetime=500 |
set |
Thanks, that solved it! How would I go about getting the scrollbar to stay longer than autocmd CursorHold * silent! lua require('scrollbar').clear() in some way to add some (non-blocking) delay before calling |
function! MyScrollbarShow() abort
let l:winnr = 0
let l:bufnr = bufnr()
if exists('b:scrollbar_timer_id') | call timer_stop(b:scrollbar_timer_id) | endif
call luaeval('require("scrollbar").show(_A[1], _A[2])', [l:winnr, l:bufnr])
let b:scrollbar_timer_id = timer_start(4000, {-> luaeval('require("scrollbar").clear(_A[1], _A[2])', [l:winnr, l:bufnr])}, {'repeat': 1})
endfunction Use the function above instead of the default Maybe this should be a feature integrated. |
eg. autocmd CursorMoved * call MyScrollbarShow() The trigger on |
@Xuyuanp Thanks, I'll give it a try! |
The solutions above show the cursor whenever the cursor is moved, even if you move it just horizontally within the same line, or if you move it vertically with @pinpox asked for an "option to only show on mouse scroll", which can be interpreted as "only show when the VIM screen is scrolled. I personally have this need since I am used to macOS' default behavior of only showing scrollbars when you scroll. I think it's probably doable in Vimscript; it doesn't look like there is a scrolling event, but one could use |
Here's my hack to show the scrollbar only when the screen itself scrolls: augroup configure_scrollbar
autocmd!
autocmd CursorMoved * call ShowScrollbar()
autocmd CursorHold,BufLeave,FocusLost,VimResized,QuitPre * silent! lua require('scrollbar').clear()
augroup end
set updatetime=500
function! ShowScrollbar()
if !exists('b:previous_first_visible_linenum') | return | endif
let first_visible_linenum = line('w0')
if first_visible_linenum != b:previous_first_visible_linenum
silent! lua require('scrollbar').show()
end
let b:previous_first_visible_linenum = first_visible_linenum
endfunction
function! OnBufEnter()
if !exists('b:previous_first_visible_linenum')
let b:previous_first_visible_linenum = line('w0')
endif
endfunction
augroup general_autocommands
autocmd!
autocmd BufEnter * call OnBufEnter()
augroup end PS: This does not show the scrollbar when scrolling with PSS:
I agree, maybe an option like |
Small feature request:
Would it be possible to show it only when I'm scrolling with the mouse wheel?
When using vim as a file viewer I would love a scrollbar.
The text was updated successfully, but these errors were encountered: