Getting a VMP Tagbar to Run When Opening Specific File Types

I want the tagbar VAR plugin to run when opening certain types of files, so I added the following to my .vimrc:

if has("gui_running") autocmd BufEnter *.hs nested TagbarOpen 

However, this does not work as I expected. It opens a side window, but the side window does not display anything, and my cursor is inside it. I cannot switch windows with one click or CTRL-W move commands.

However, when I launch TagbarOpen manually, it works fine.

Has anyone else tried this or the wrong command came out?

+7
source share
2 answers

Interestingly, I did not expect a side effect of convenient functionality. What happens: if TagbarOpen is called when the window is already open, Tagbar forces the cursor to go to its window instead of just doing nothing (for convenience, as I said). Therefore, every time you try to leave the window, switching to the Haskell window, the auto command makes it jump to the right. I clicked a change that removes this functionality - probably it was not so useful to start. Therefore, if you give the development version on GitHub a try ( https://github.com/majutsushi/tagbar ), it should work.

There is another reason for the window to be empty: Haskell is not supported by Exuberant Ctags by default. But someone wrote a good alternative for Haskell that works with Tagbar here: https://github.com/bitc/lushtags .

+6
source

Actually, I have this fine tuning configured for vprc for php files. The Tagbar opens with the loaded function / variables, the cursor remains in the php source file when Vim loads:

 autocmd FileType php call SetPHPOptions() function! SetPHPOptions() setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab makeprg=php-xdebug\ % :call tagbar#autoopen(0) endfunction 

replace "php" with "hs" or any other type of file you want. List of file types:

 $VIMRUNTIME/filetype.vim 

Try running MacVim (image 72, Vim 7.4) and the latest tagbar from https://github.com/majutsushi/tagbar

+3
source

All Articles