ludovicchabant/vim-gutentags

Gutentags regenerating entire tags file every time project is opened

bernastoc opened this issue · 3 comments

Issue and steps
Upon loading a file from my project's root directory, where a 'tags' exists and is current, gutentags will immediately call ctags i.e. "ctags -f tags.temp --options=/home/username/.config/nvim/vim-plug/vim-gutentags/res/ctags_recursive.options ..."

By running htop in another window I can tell when gutentags has finished running. If I close neovim at this point and re-open the same code file, gutentags runs again. Checking the timestamp of the 'tags' file, I can see it's modified each time I open my project file (despite making no changes to the code). I have a rather large codebase so it's impossible to miss when ctags is running since it pegs my CPU for a while.

My Setup
CentOS Linux release 7.8.2003 (Core)
Neovim NVIM v0.5.0-654-g3acfefb63
ctags --version:
Universal Ctags 0.0.0(3f0ea94c), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Aug 5 2020, 15:39:19
URL: https://ctags.io/
Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +packcc

I'm not using g:gutentags_cache_dir nor have I set any gutentags flags other than gutentags_ctags_extra_args.

Logs
gutentags: [job stdout]: ['Locking tags file...', 'Running ctags on whole project', 'ctags -f "tags.temp" "--options=/home/username/.config/nvim/vim-plug/vim-gutentags/res/ctags_recursive.options" --kinds-C=+pxL --kinds-C++=+pxL --fields-C=+{macrodef}{properties} --fields=+{signature}{access} --exclude="one" --exclude="two" --exclude="three" --exclude="etc" "."', '']
gutentags: [job stdout]: ['Replacing tags file', 'mv -f "tags.temp" "tags"', '']
gutentags: [job stdout]: ['Unlocking tags file...', '']
gutentags: [job stdout]: ['Done.', '']
gutentags: [job stdout]: ['']
gutentags: [job stderr]: ['']
gutentags: Finished ctags job.

I couldn't find a tags.log file anywhere, sorry.

Extra Context
Here are the ctags arguments I use:

Manual run at bash prompt:
ctags --recurse
--kinds-C=+pxL
--kinds-C++=+pxL
--fields-C=+{macrodef}{properties}
--fields=+{signature}{access}
--exclude="one"
--exclude="two"
--exclude="three"
--exclude="etc"

And in my init.vim:
let g:gutentags_ctags_extra_args=
[ '--kinds-C=+pxL',
\ '--kinds-C++=+pxL',
\ '--fields-C=+{macrodef}{properties}',
\ '--fields=+{signature}{access}',
\ '--exclude="agent/ti-mibs*"',
\ '--exclude="one"',
\ '--exclude="two"',
\ '--exclude="three"',
\ '--exclude="etc"' ]

Somehow the gutentags generated tags file is 2x the size of the one I generate at the command prompt, but I guess that's a separate issue.

Hi,

Yes, gutentags, by default, runs on the entire project on the first opened file. The reasoning is that anything could have happened since the last time you closed Vim (pulled/updated the repository is a common one), so gutentags gets ahead of things.

You can set g:gutentags_generate_on_new to 0 to disable this.

Ideally we would just update the tags file by reparsing the source files that are newer (as opposed to the whole project), but I don't know if that's easily possible.

Thanks. I let g:gutentags_generate_on_new=0 and I'm seeing the behavior I expected.

Hi,

Yes, gutentags, by default, runs on the entire project on the first opened file. The reasoning is that anything could have happened since the last time you closed Vim (pulled/updated the repository is a common one), so gutentags gets ahead of things.

You can set g:gutentags_generate_on_new to 0 to disable this.

Ideally we would just update the tags file by reparsing the source files that are newer (as opposed to the whole project), but I don't know if that's easily possible.

If we restricted scenario on git, maybe we can only update the entire tag file when the HEAD is moved?