Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting VIM Tagbar to launch when opening certain file types

Tags:

vim

tagbar

I'd like to have the tagbar VIM plugin launch when I open certain filetypes, so I added the following to my .vimrc:

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

However, this isn't working as I expected. It opens a side window, but the side window displays nothing and my cursor is trapped within it. I cannot switch windows with a click or with the CTRL-W movement commands.

However, when I run TagbarOpen manually, it works just fine.

Anyone else tried this, or is the above the wrong command to issue?

like image 985
Ana Avatar asked Nov 02 '11 14:11

Ana


1 Answers

Interesting, that's a side effect of a convenience functionality that I hadn't anticipated. What happens is this: If TagbarOpen is called while the window is already open, Tagbar makes the cursor jump to its window instead of just doing nothing (for convenience like I said). So every time you try to leave the window by switching to the Haskell window, the autocommand causes it to jump right back. I've pushed a change that removes this functionality -- it probably wasn't that useful to begin with. So if you give the development version on GitHub a try (https://github.com/majutsushi/tagbar), it should work.

That the window is empty has a different reason: Haskell is not supported by Exuberant Ctags by default. But someone wrote a nice alternative for Haskell that works with Tagbar here: https://github.com/bitc/lushtags.

like image 167
Jan Larres Avatar answered Oct 07 '22 03:10

Jan Larres