Taglist-like Vim plugin for Rust?

Does anyone know of a Vim plugin similar to taglist for Rust?
Taglist is a source code browser that opens in a side pane. It shows classes, methods, and other declarations.
It's useful for having an overview, especially of larger projects consisting of multiple files.

I know of racer-vim but it provides jump-to-definition and jump-to-help but not this. There's also rusty-tags however I was unable to get its output to work with taglist in vim.

1 Like

I've been using tagbar, but it's not ideal either for rust. What we really need is a good etags implementation for rust.

3 Likes

ya that would be great
I've went with NERDTree for now, at least having a file list of the project gives me some overview, together with racer's jump-to-definition it's more or less convenient
should probably switch to a real IDE at some point but doesn't really like something closed-source or overly heavy

1 Like

The primary reasons I use vim are (1) convenience... I'm already in the terminal and I don't want to switch to another window; (2) keyboard-oriented: I don't like using mice; and (3) it's already installed on most linux/macos boxes. I don't think any IDE will ever have those features in the near-term...

Really, my rust/vim setup is pretty nice. The only thing missing is something like etags/tagbar/taglist.

3 Likes

More or less all the same reasons for me!

Just at times like this, hunting plugins, I wonder if I'm not spending too much time fighting my editor. Overall it's nice though and I'm very used to it.

What's not ideal about tagbar? Works great for me.

1 Like

thanks a lot for the suggestions @mark-i-m @anon15139276 @lkurusa will check them out!

Edit: looks like tagbar was exactly what I was looking for; the difference with taglist is that it shows only the tags for the current file and not for the entire project, but that's ok as I have a tree browser too now.

I will try that out @anon15139276! Thanks :slight_smile:

@lkurusa If you have used tagbar with C++, you will note the difference :wink:

Just noticed that if a recent version of rust-vim plugin is installed, the changes to ~/.ctags and g:tagbar_type_rust are unnecessary—will even result in every tag being shown twice

1 Like

@lkurusa I posted a more elaborate response here: Rust 2019: Technical Debt, Continued Productivity, and Stability - #3 by mark-i-m - Rust Internals

1 Like

Thank you. I now see what could be improved.

1 Like

I had a similar problem with Tagbar, but it turns out that universal-ctags has better native Rust support and this can be integrated with Tagbar in a nice way.

  1. Build and install universal-ctags
  2. Put the following in your .vimrc:
let g:rust_use_custom_ctags_defs = 1
let g:tagbar_type_rust = {
  \ 'ctagsbin' : '/path/to/your/universal/ctags',
  \ 'ctagstype' : 'rust',
  \ 'kinds' : [
      \ 'n:modules',
      \ 's:structures:1',
      \ 'i:interfaces',
      \ 'c:implementations',
      \ 'f:functions:1',
      \ 'g:enumerations:1',
      \ 't:type aliases:1:0',
      \ 'v:constants:1:0',
      \ 'M:macros:1',
      \ 'm:fields:1:0',
      \ 'e:enum variants:1:0',
      \ 'P:methods:1',
  \ ],
  \ 'sro': '::',
  \ 'kind2scope' : {
      \ 'n': 'module',
      \ 's': 'struct',
      \ 'i': 'interface',
      \ 'c': 'implementation',
      \ 'f': 'function',
      \ 'g': 'enum',
      \ 't': 'typedef',
      \ 'v': 'variable',
      \ 'M': 'macro',
      \ 'm': 'field',
      \ 'e': 'enumerator',
      \ 'P': 'method',
  \ },
\ }
  1. Restart vim and enjoy!

8 Likes

Thanks, that's a great setup, so much more detailed than the default tagbar one.

1 Like

@tmandry You made my day!

2 Likes

How to make it show which trait is being implemented?

For impl Foo for Bar it shows just "Bar: implementation", having "Foo" there would be helpful.