From c4b045cc6dd442120ebe388ab31306a6bd15176f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 30 Jul 2024 18:53:14 +0800 Subject: [PATCH] refactor(scrollbar): detach scrollbar --- .ci/detach_plugin.sh | 4 ++- autoload/SpaceVim/layers/ui.vim | 21 +++----------- bundle/scrollbar.vim/README.md | 35 +++++++++++++++++++++++ bundle/scrollbar.vim/plugin/scrollbar.vim | 26 +++++++++++++++++ 4 files changed, 68 insertions(+), 18 deletions(-) create mode 100644 bundle/scrollbar.vim/README.md create mode 100644 bundle/scrollbar.vim/plugin/scrollbar.vim diff --git a/.ci/detach_plugin.sh b/.ci/detach_plugin.sh index 515391880..f0d2ef844 100755 --- a/.ci/detach_plugin.sh +++ b/.ci/detach_plugin.sh @@ -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 diff --git a/autoload/SpaceVim/layers/ui.vim b/autoload/SpaceVim/layers/ui.vim index a1fda03f1..77d928256 100644 --- a/autoload/SpaceVim/layers/ui.vim +++ b/autoload/SpaceVim/layers/ui.vim @@ -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 :TagbarToggle 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() diff --git a/bundle/scrollbar.vim/README.md b/bundle/scrollbar.vim/README.md new file mode 100644 index 000000000..ded7f688f --- /dev/null +++ b/bundle/scrollbar.vim/README.md @@ -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) + + + +- [Install](#install) +- [Feedback](#feedback) + + + +## 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) diff --git a/bundle/scrollbar.vim/plugin/scrollbar.vim b/bundle/scrollbar.vim/plugin/scrollbar.vim new file mode 100644 index 000000000..a31a2fad3 --- /dev/null +++ b/bundle/scrollbar.vim/plugin/scrollbar.vim @@ -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