liuchengxu / vista.vim

:cactus: Viewer & Finder for LSP symbols and tags
https://liuchengxu.github.io/vista.vim
MIT License
1.9k stars 87 forks source link

Vista windows stays open when doing an `fzf` search #379

Closed farzadmf closed 3 years ago

farzadmf commented 3 years ago

Describe the bug Vista window doesn't close after doing fzf search despite having set the option let g:vista_close_on_jump = 1

Environment:

didn't include other details because I think they're not relevant to this bug

Vista info

    let g:vista = {'get_tagline_under_cursor': function('424'), 'winnr': function('422'), 'source': {'fname': '', 'bufnr': 2, 'get_winid': function('426'), 'winid': 1000, 'winnr': 1, 'extension': function('431'), 'line': function('429'), 'get_winnr': function('425'), 'fil
etype': function('427'), 'lines': function('428'), 'line_trimmed': function('430'), 'scope_seperator': function('432'), 'fpath': ''}, 'winid': function('423'), 'tmps': []}
    let g:vista#executives = ['ale', 'coc', 'ctags', 'lcn', 'nvim_lsp', 'vim_lsc', 'vim_lsp']
    let g:vista#extensions = ['markdown', 'rst']
    let g:vista#finders = ['clap', 'fzf', 'skim']
    let g:vista_blink = [2, 100]
    let g:vista_close_on_jump = 1
    let g:vista_cursor_delay = 400
    let g:vista_default_executive = 'ctags'
    let g:vista_disable_statusline = 1
    let g:vista_echo_cursor = 1
    let g:vista_enable_centering_jump = 1
    let g:vista_executive_for = {}
    let g:vista_find_absolute_nearest_method_or_function = 0
    let g:vista_find_nearest_method_or_function_delay = 300
    let g:vista_fold_toggle_icons = ['▼', '▶']
    let g:vista_fzf_preview = ['right:50%']
    let g:vista_highlight_whole_line = 1
    let g:vista_icon_indent = ['└ ', '│ ']
    let g:vista_ignore_kinds = []
    let g:vista_no_mappings = 0
    let g:vista_sidebar_position = 'vertical botright'
    let g:vista_sidebar_width = 70
    let g:vista_stay_on_open = 1
    let g:vista_top_level_blink = [2, 100]
    let g:vista_update_on_text_changed = 0
    let g:vista_update_on_text_changed_delay = 500

Steps to reproduce given the above info As mentioned in the help, I've setup my / key to do an fzf search:

 autocmd FileType vista,vista_kind nnoremap <buffer> <silent> \
             / :<c-u>call vista#finder#fzf#Run()<CR>
  1. Set up the key binding
  2. Go to a file and do :Vista to open the window
  3. Press / to do a search
  4. Select a tag by pressing ENTER

Expected behavior I expect that when I search using / and select to "jump" to that tag, the vista Window to be closed, but it stays open

Actual behavior After doing the search and "jumping", vista is still open

liuchengxu commented 3 years ago

let g:vista_close_on_jump = 1 is to close the vista window when you jump to a symbol in the source file from the vista window, not for closing it when you select an item from the fzf window.

farzadmf commented 3 years ago

Thank you @liuchengxu for your answer, so there's no way to close automatically then?

liuchengxu commented 3 years ago

No such option now, but you can try this:

diff --git a/autoload/vista/finder/fzf.vim b/autoload/vista/finder/fzf.vim
index 63a514e..5ea0cd4 100644
--- a/autoload/vista/finder/fzf.vim
+++ b/autoload/vista/finder/fzf.vim
@@ -94,6 +94,7 @@ function! vista#finder#fzf#sink(line, ...) abort
   call cursor(lnum, col)
   normal! zz
   call call('vista#util#Blink', get(g:, 'vista_blink', [2, 100]))
+  call vista#sidebar#Close()
 endfunction

 " Actually call fzf#run() with a highlighter given the opts
farzadmf commented 3 years ago

That's great, I'm gonna give it a try, thank you :slightly_smiling_face:


Hey @liuchengxu , it works with the patch you provided. Does it hurt to add that line in the main code? I guess it should be fine since the FZF window is automatically closed when we select something, so it's somehow expected for the main window to close as well

liuchengxu commented 3 years ago

You can use let g:vista_close_on_fzf_select = 1 now.

farzadmf commented 3 years ago

Wow, amazing, thank you @liuchengxu