From 3c795e6d422adaa66fa53012962870a7e2b53e03 Mon Sep 17 00:00:00 2001 From: blankname Date: Sat, 17 Oct 2020 00:33:16 -0400 Subject: [PATCH] Some fixes for FlyGrep (#3908) --- .ci/detach_plugin.sh | 15 ++++++++++----- autoload/SpaceVim/api/vim/statusline.vim | 6 ++++-- autoload/SpaceVim/plugins/flygrep.vim | 4 ++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.ci/detach_plugin.sh b/.ci/detach_plugin.sh index 94cee832c..0b755c186 100755 --- a/.ci/detach_plugin.sh +++ b/.ci/detach_plugin.sh @@ -38,7 +38,12 @@ main () { _detect autoload/SpaceVim/api/vim/buffer.vim _detect autoload/SpaceVim/api/vim/regex.vim _detect autoload/SpaceVim/api/vim/compatible.vim + _detect autoload/SpaceVim/api/vim/floating.vim + _detect autoload/SpaceVim/api/vim/highlight.vim + _detect autoload/SpaceVim/api/vim/statusline.vim + _detect autoload/SpaceVim/api/vim/window.vim _detect autoload/SpaceVim/api/neovim/floating.vim + _detect autoload/SpaceVim/api/data/dict.vim _detect autoload/SpaceVim/api/data/list.vim _detect autoload/SpaceVim/api/data/json.vim _detect autoload/SpaceVim/api/prompt.vim @@ -77,21 +82,21 @@ main () { "" " FlyGrep will start to searching code after a delay, the default value is " 500ms. -let g:FlyGrep_input_delay = 500 +let g:FlyGrep_input_delay = get(g:, 'FlyGrep_input_delay', 500) "" " A list of searching tools will be userd. -let g:FlyGrep_search_tools = ['ag', 'rg', 'grep', 'pt', 'ack'] +let g:FlyGrep_search_tools = get(g:, 'FlyGrep_search_tools', ['ag', 'rg', 'grep', 'pt', 'ack']) -let g:spacevim_data_dir = '~/.cache' +let g:spacevim_data_dir = get(g:, 'spacevim_data_dir', '~/.cache') "" " Enable FlyGrep statusline -let g:FlyGrep_enable_statusline = 1 +let g:FlyGrep_enable_statusline = get(g:, 'FlyGrep_enable_statusline', 1) "" " Set FlyGrep default command prompt -let g:spacevim_commandline_prompt = '➭' +let g:spacevim_commandline_prompt = get(g:, 'spacevim_commandline_prompt', '➭') command! -nargs=0 FlyGrep call FlyGrep#open({}) EOT diff --git a/autoload/SpaceVim/api/vim/statusline.vim b/autoload/SpaceVim/api/vim/statusline.vim index c7a856a93..be1d575d4 100644 --- a/autoload/SpaceVim/api/vim/statusline.vim +++ b/autoload/SpaceVim/api/vim/statusline.vim @@ -167,11 +167,13 @@ endfunction if s:self.__floating.exists() function! s:self.close_float() abort - call self.__floating.win_close(self.__winid, 1) + if get(self, '__winid', -1) != -1 + call self.__floating.win_close(self.__winid, 1) + endif endfunction else function! s:self.close_float() abort - if has_key(self, '__winid') && win_id2tabwin(self.__winid)[0] == tabpagenr() + if get(self, '__winid', -1) != -1 && win_id2tabwin(self.__winid)[0] == tabpagenr() noautocmd execute win_id2win(self.__winid).'wincmd w' noautocmd close endif diff --git a/autoload/SpaceVim/plugins/flygrep.vim b/autoload/SpaceVim/plugins/flygrep.vim index 2194b2eb4..ab1dba3cb 100644 --- a/autoload/SpaceVim/plugins/flygrep.vim +++ b/autoload/SpaceVim/plugins/flygrep.vim @@ -913,6 +913,10 @@ endfunction " }}} function! s:update_statusline() abort + if !g:FlyGrep_enable_statusline + return + endif + if s:SL.support_float() && win_id2tabwin(s:flygrep_win_id)[0] ==# tabpagenr() && s:Window.is_float(win_id2win(s:flygrep_win_id)) noautocmd call s:SL.open_float([ \ ['FlyGrep ', 'SpaceVim_statusline_a_bold'],