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

Clap tags not showing on buffer enter until the buffer is saved #237

Open bigardone opened 4 years ago

bigardone commented 4 years ago

Environment (please complete the following information):

Describe the bug When running :Clap tags after opening a file, the tags won't show in the popup until you save the buffer for the first time. If you open a different file and come back again to the first one, the same behavior happens and it does not show any tags until you save the buffer.

Clap debug

            has cargo: 1
            has maple: /Users/ricardogarciavega/.nvim/plugged/vim-clap/target/release/maple
           maple info: version 0.1.7, built for x86_64-apple-darwin by rustc 1.37.0.
         has +python3: 1
has py dynamic module: 0
     Current FileType: elm
Third Party Providers: []
       Global Options:
    let g:clap#autoload_dir = '/Users/ricardogarciavega/.nvim/plugged/vim-clap/autoload'
    let g:clap#provider_alias = {'gfiles': 'git_files', 'hist:': 'command_history', 'hist/': 'search_history'}
    let g:clap_disable_bottom_top = 0
    let g:clap_enable_icon = 0
    let g:clap_forerunner_status_sign = {'done': '•', 'running': '!'}
    let g:clap_layout = {'width': '75%', 'relative': 'editor'}
    let g:clap_no_matches_msg = 'NO MATCHES FOUND'
    let g:clap_open_action = {'ctrl-v': 'vsplit', 'ctrl-x': 'split', 'ctrl-t': 'tab split'}
    let g:clap_search_box_border_style = 'curve'
    let g:clap_search_box_border_symbols = {'nil': ['', ''], 'curve': ['', ''], 'arrow': ['', '']}
  Provider Variables:
                     []

To Reproduce Steps to reproduce the behavior:

  1. Create the minimal vimrc min.vim:
set nocompatible
filetype off

call plug#begin('~/.nvim/plugged')

Plug 'junegunn/vim-plug'

" Put your bundle below here
Plug 'liuchengxu/vim-clap'
Plug 'liuchengxu/vista.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Put your bundle above here

call plug#end()

syntax on
filetype plugin indent on

" Put your plugin settings below here
""""""""""""""""""""""""""
" Vista configuration
""""""""""""""""""""""""""
let g:vista_default_executive = 'coc'

" Put your plugin settings above here
  1. Start (neo)vim with command: vim -u min.vim

  2. Open a file.

  3. Type ':Clap tags'

  4. Check that no symbols are listed in the popup.

  5. Add a blank line to the file and save it.

  6. Type ':Clap tags'.

  7. Check that the symbols are listed correctly.

  8. Open a different file in a different buffer.

  9. Go back to the initial buffer.

  10. Type ':Clap tags'

  11. Check that no symbols are listed anymore.

Expected behavior Typing :Clap tags after opening a file should list symbols like Vista does, without having to previously save the file.

Screenshots First time:

image

After saving the file:

image

After going to the next buffer and back:

image

Additional context

This week I reported this issue, https://github.com/liuchengxu/vista.vim/issues/234, could it be related?

liuchengxu commented 4 years ago

Check out :echo CocAction('documentSymbols') when there is no symbols. If coc returns nothing, then it's not an issue of vista.vim.

Also try adding this for debugging, see if coc returns the symbols on that moment.

diff --git a/autoload/vista/executive/coc.vim b/autoload/vista/executive/coc.vim
index 8b36615..cd62e20 100644
--- a/autoload/vista/executive/coc.vim
+++ b/autoload/vista/executive/coc.vim
@@ -48,6 +48,7 @@ function! s:AutoUpdate(_fpath) abort
 endfunction

 function! s:Run() abort
+  echom 'coc symbols:'.string(CocAction('documentSymbols'))
   return s:Extract(CocAction('documentSymbols'))
 endfunction
bigardone commented 4 years ago

Thanks for the response!

Opening a new file and running :echo CocAction('documentSymbols') displays all the symbols:

image

However, clap/vista don't display any symbols:

image

However, doing it a second time, neither Coc or Clap/Vista no longer display any symbols:

image

If adding a blank line and saving, everything works as expected:

image

However, if I run :echo CocAction('documentSymbols'), it does not list any symbols at all, which is very confusing.

image

liuchengxu commented 4 years ago

vim-clap relys on vista.vim to fetch the symbols, and vista.vim actually uses the API of coc.nvim CocAction('documentSymbols'). clap/vista.vim can do nothing if coc returns nothing.

What's more, I suggest you to setup ctags too, so that vista.vim can fallback to the ctags way, then you normally can get some tags response.

bigardone commented 4 years ago

That makes sense. However, I'm going to open an issue in Coc reporting that CocAction('documentSymbols') returns null until the file gets saved. Thanks :)