Skip to content

Commit af2fb77

Browse files
committed
Avoid overriding Tagbar's configuration if Universal Ctags are detected
1 parent 0e0a067 commit af2fb77

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ for more details.
4141

4242
### Source browsing with [Tagbar][tgbr]
4343

44-
`rust.vim` has builtin `ctags/` definitions for [Tagbar][tgbr] which
45-
are loaded if Tagbar is installed.
44+
The installation of Tagbar along with [Universal Ctags](uctags) is recommended
45+
for a good Tagbar experience. For other kinds of setups, `rust.vim` tries to
46+
configure Tagbar to some degree.
4647

4748
### Formatting with [rustfmt][rfmt]
4849

@@ -102,6 +103,7 @@ LICENSE-MIT for details.
102103
[rfmt]: https://github.com/rust-lang-nursery/rustfmt
103104
[syn]: https://github.com/scrooloose/syntastic
104105
[tgbr]: https://github.com/majutsushi/tagbar
106+
[uctags]: https://ctags.io
105107
[wav]: https://github.com/mattn/webapi-vim
106108
[pp]: https://play.rust-lang.org/
107109
[vim8pack]: http://vimhelp.appspot.com/repeat.txt.html#packages

autoload/rust/tags.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
" Tagbar support code, for the sake of not automatically overriding its
2+
" configuration in case Universal Ctags is detected.
3+
4+
let s:ctags_is_uctags = 0
5+
let s:checked_ctags = 0
6+
7+
function! rust#tags#IsUCtags() abort
8+
if s:checked_ctags == 0
9+
if system('ctags --version') =~? 'universal ctags'
10+
let s:ctags_is_uctags = 1
11+
endif
12+
let s:checked_ctags = 1
13+
endif
14+
return s:ctags_is_uctags
15+
endfunction
16+
17+
" vim: set et sw=4 sts=4 ts=8:

doc/rust.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,17 @@ g:rust_use_custom_ctags_defs~
9191
and do not wish for those included with rust.vim to be used: >
9292
let g:rust_use_custom_ctags_defs = 1
9393
<
94-
Note that rust.vim's built-in definitions are only used for the Tagbar
95-
Vim plugin, if you have it installed--it is not automatically used
96-
when generating |tags| files that Vim can use to navigate to
97-
definitions across different source files. Feel free to copy
98-
`rust.vim/ctags/rust.ctags` into your own `~/.ctags` if you wish to
99-
generate |tags| files.
94+
95+
NOTE: rust.vim's built-in definitions are only used for the Tagbar Vim
96+
plugin, if you have it installed, AND if Universal Ctags is not
97+
detected. This is because Universal Ctags already has built-in
98+
support for Rust when used with Tagbar.
99+
100+
Also, note that when using ctags other than Universal Ctags, it is not
101+
automatically used when generating |tags| files that Vim can use to
102+
navigate to definitions across different source files. Feel free to
103+
copy `rust.vim/ctags/rust.ctags` into your own `~/.ctags` if you wish
104+
to generate |tags| files.
100105

101106

102107
*g:ftplugin_rust_source_path*

ftplugin/rust/tagbar.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"
22
" Support for Tagbar -- https://github.com/majutsushi/tagbar
33
"
4-
if !exists(':Tagbar') || system('ctags --version') =~? 'universal ctags'
4+
if !exists(':Tagbar') || rust#tags#IsUCtags()
55
finish
66
endif
77

0 commit comments

Comments
 (0)