vista.vim

Vista.vim is my attempt to replacing tagbar, which was a great plugin for displaying ctags nicely in a sidebar. Many vimmers would say tagbar is a must-have vim plugin and I do love it in the past, but after the emergence of Language Server Protocl and async functionality of Vim8/NeoVim, I’m not satisfied any more:

  • LSP has document symbols, which gives you a flat list of all symbols found in a given text document. Although this functionality sounds similar to ctags, the thing is that these document symbols understand the semantics while the tags generated from ctags is based on regex only.

  • Vim will never be blocked if we can update asynchorounously in the background. In most cases, it’s not a problem to update ctags in sync way, ctags is fast enough to return the result. But with the job feature of Vim8/NeoVim, we can could it better, so why not?

Tagbar has not been updated for a long while, so I started vista.vim to obtain the features above for myself. After merging this PR for supporting nested ctags display, now I believe vista.vim has become a superset of tagbar, and I think it’s good enough to share with you.

Vista.vim now supports both ctags and most Vim LSP plugins:

You can view the items provided by these clients in a sidebar in a decent way.

vista.vim

Besides being a tags/LSP symbols viewer, vista.vim also could serve as a finder for these information similar to the function navigator for ctrlp.vim ctrlp-funky. As I’m a big fan of fzf, vista.vim can use fzf to filter the symbols gathered.

vista.vim

In the gif above I use the latest floating window feature of neovim to open fzf window in the center, which is utterly cool in this use case. In order to achieve that, you have to:

  1. Upgrade your neovim if it doesn’t have the floating window api, :h api-floatwin.

  2. Then configure fzf to open in a floating window, refer to https://github.com/junegunn/fzf.vim/issues/664 as well.

         let $FZF_DEFAULT_OPTS = '--layout=reverse'
    
         let g:fzf_layout = { 'window': 'call OpenFloatingWin()' }
    
         function! OpenFloatingWin()
           let height = &lines - 3
           let width = float2nr(&columns - (&columns * 2 / 10))
           let col = float2nr((&columns - width) / 2)
    
           let opts = {
                 \ 'relative': 'editor',
                 \ 'row': height * 0.3,
                 \ 'col': col + 30,
                 \ 'width': width * 2 / 3,
                 \ 'height': height / 2
                 \ }
    
           let buf = nvim_create_buf(v:false, v:true)
           let win = nvim_open_win(buf, v:true, opts)
    
           call setwinvar(win, '&winhl', 'Normal:Pmenu')
    
           setlocal
                 \ buftype=nofile
                 \ nobuflisted
                 \ bufhidden=hide
                 \ nonumber
                 \ norelativenumber
                 \ signcolumn=no
         endfunction
    

For detailed usage, please see the README on github and :h vista. Let me know if you run into any issues via the issue tracker. ⤧  Next post Make Vim Python plugin 10x faster using Rust ⤧  Previous post Vim Port of spacemacs-theme