1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 07:00:04 +08:00

refactor(scrollbar): detach scrollbar

This commit is contained in:
Eric Wong 2024-07-30 18:53:14 +08:00
parent 2c92c0b51f
commit c4b045cc6d
4 changed files with 68 additions and 18 deletions

View File

@ -436,7 +436,9 @@ EOT
_checkdir autoload/SpaceVim/plugins/
_detact autoload/SpaceVim/plugins/scrollbar.vim
_detact LICENSE
_default_readme "scrollbar.vim" "floating scrollbar support for neovim/vim[wip]"
_detact_bundle scrollbar.vim README.md
_checkdir plugin
_detact_bundle scrollbar.vim plugin/scrollbar.vim
;;
GitHub.vim)
git clone https://github.com/wsdjeg/GitHub.vim.git detach/$1

View File

@ -113,6 +113,10 @@ function! SpaceVim#layers#ui#plugins() abort
call add(plugins, [g:_spacevim_root_dir . 'bundle/vim-airline-themes',
\ { 'merged' : 0}])
endif
if s:enable_scrollbar
call add(plugins, [g:_spacevim_root_dir . 'bundle/scrollbar.vim',
\ { 'merged' : 0}])
endif
return plugins
@ -171,20 +175,8 @@ function! SpaceVim#layers#ui#config() abort
noremap <silent> <F2> :TagbarToggle<CR>
endif
" this options only support neovim now.
augroup spacevim_layer_ui
autocmd!
let events = join(filter( ['BufEnter','WinEnter', 'QuitPre', 'CursorMoved', 'VimResized', 'FocusGained', 'WinScrolled' ], 'exists("##" . v:val)'), ',')
if s:enable_scrollbar && SpaceVim#plugins#scrollbar#usable()
exe printf('autocmd %s * call SpaceVim#plugins#scrollbar#show()',
\ events)
autocmd WinLeave,BufLeave,BufWinLeave,FocusLost
\ * call SpaceVim#plugins#scrollbar#clear()
" why this autocmd is needed?
"
" because the startify use noautocmd enew
autocmd User Startified call s:clear_previous_scrollbar()
endif
if !empty(s:cursorword_exclude_filetypes)
exe printf('autocmd FileType %s let b:cursorword = 0',
\ join(s:cursorword_exclude_filetypes, ','))
@ -642,11 +634,6 @@ function! SpaceVim#layers#ui#set_variable(var) abort
\ ))
endfunction
function! s:clear_previous_scrollbar() abort
let bufnr = bufnr('#')
call SpaceVim#plugins#scrollbar#clear(bufnr)
endfunction
function! SpaceVim#layers#ui#health() abort
call SpaceVim#layers#ui#plugins()
call SpaceVim#layers#ui#config()

View File

@ -0,0 +1,35 @@
# scrollbar.vim
> _scrollbar.vim_ is floating scrollbar plugin for vim and neovim.
[![](https://spacevim.org/img/build-with-SpaceVim.svg)](https://spacevim.org)
[![GPLv3 License](https://img.spacevim.org/license-GPLv3-blue.svg)](LICENSE)
<!-- vim-markdown-toc GFM -->
- [Install](#install)
- [Feedback](#feedback)
<!-- vim-markdown-toc -->
## Install
1. Using `scrollbar.vim` in SpaceVim:
```toml
[[layers]]
name = 'ui'
enable_scrollbar = true
```
2. Using `scrollbar.vim` without SpaceVim:
```
Plug 'wsdjeg/scrollbar.vim'
```
## Feedback
The development of this plugin is in [`SpaceVim/bundle/scrollbar.vim`](https://github.com/SpaceVim/SpaceVim/tree/master/bundle/scrollbar.vim) directory.
If you encounter any bugs or have suggestions, please file an issue in the [issue tracker](https://github.com/SpaceVim/SpaceVim/issues)

View File

@ -0,0 +1,26 @@
"=============================================================================
" scrollbar.vim --- scrollbar plugin for vim and neovim
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
function! s:clear_previous_scrollbar() abort
let bufnr = bufnr('#')
call SpaceVim#plugins#scrollbar#clear(bufnr)
endfunction
augroup spacevim_scrollbar
autocmd!
let events = join(filter( ['BufEnter','WinEnter', 'QuitPre', 'CursorMoved', 'VimResized', 'FocusGained', 'WinScrolled' ], 'exists("##" . v:val)'), ',')
if SpaceVim#plugins#scrollbar#usable()
exe printf('autocmd %s * call SpaceVim#plugins#scrollbar#show()',
\ events)
autocmd WinLeave,BufLeave,BufWinLeave,FocusLost
\ * call SpaceVim#plugins#scrollbar#clear()
" why this autocmd is needed?
"
" because the startify use noautocmd enew
autocmd User Startified call s:clear_previous_scrollbar()
endif
augroup end