preservim / tagbar

Vim plugin that displays tags in a window, ordered by scope
https://preservim.github.io/tagbar
Other
6.14k stars 489 forks source link

Question: can tagbar use same ctags file as gutentags? #872

Open lijh8 opened 9 months ago

lijh8 commented 9 months ago

Hi, currently, both tagbar and gutentags work on my computer. gutentags will generate tags file in the same directory with .git, will tagbar use this tags file too?

Thanks


$ tree -a

.
└── src
    ├── .git
    ├── main
    │   ├── Makefile
    │   ├── foo.cpp
    │   ├── foo.h
    │   └── main.cpp
    └── tags

$ $ ls src/.git $ ls src/tags src/tags $

$ cat ~/.vimrc

"" Tagbar
" https://github.com/preservim/tagbar/issues/851
autocmd QuitPre * qall
autocmd VimEnter * Tagbar
let g:tagbar_sort = 0
nnoremap <F8> :TagbarToggle<CR>

"" gutentags: ctags: Ctrl-], Ctrl-t
" $ mkdir ~/project_root_dir/.git
let g:gutentags_add_default_project_roots = 1

$

raven42 commented 9 months ago

Based on the current tagbar implementation, no it will not use any pre-generated tagfiles. The current behavior of tagbar is it will generate a tagfile for the open buffer in a temporary file to read the contents from that. So you don't need any existing tag files or anything. This has the benefit of being able to update the tags from the file every time it is written as well, so it isn't reliant on another process to generate new tag files.