Subject: bug#67687: Feature request: automatic tags management

From: Jon Eskin <[email-masked]>
Date: Thu, 7 Dec 2023 14:57:08 -0500

Hi Dmitry!

> I have some related work that's been lying in a drawer as of late.
> 
> Do you know what gutentags does when a file is deleted, or added externally, or you switch to a different Git branch and many files change their contents at once?

To my knowledge, changes to tags due to files being added or deleted are regenerated only when vim is started inside the project. Switching to a different git branch should work the same, because it’s only looking at the filesystem.

If the editor is already running, such changes will not be picked up; even if you try to navigate to a tag that no longer exists, I do not believe that it will regenerate tags automatically until you close and re-open the editor.

When you save a file inside the editor, it will wipe out tags for that individual file and regenerate them.

Here are some docs for customization options you might find interesting:

  *gutentags_generate_on_missing*
g:gutentags_generate_on_missing
                        If set to 1, Gutentags will start generating an initial
                        tag file if a file is open in a project where no tags
                        file is found. See |gutentags_project_root| for how
                        Gutentags locates the project.
                        When set to 0, Gutentags will only generate the first
                        time the file is saved (if
                        |gutentags_generate_on_write| is set to 1), or when
                        |GutentagsUpdate| or |GutentagsGenerate| is run.
                        Defaults to 1.

                                                *gutentags_generate_on_new*
g:gutentags_generate_on_new
                        If set to 1, Gutentags will start generating the tag
                        file when a new project is open. A new project is
                        considered open when a buffer is created for a file
                        whose corresponding tag file has not been "seen" yet
                        in the current Vim session -- which pretty much means
                        when you open the first file in a given source control
                        repository.
                        When set to 0, Gutentags won't do anything special.
                        See also |gutentags_generate_on_missing| and
                        |gutentags_generate_on_write|.
                        Defaults to 1.

                                                *gutentags_generate_on_write*
g:gutentags_generate_on_write
                        If set to 1, Gutentags will update the current
                        project's tag file when a file inside that project is
                        saved. See |gutentags_project_root| for how Gutentags
                        locates the project.
                        When set to 0, Gutentags won't do anything on save.
                        This means that the project's tag file won't reflect
                        the latest changes, and you will have to run
                        |GutentagsUpdate| manually.
                        Defaults to 1.

                                            *gutentags_generate_on_empty_buffer*
g:gutentags_generate_on_empty_buffer
                        If set to 1, Gutentags will start generating the tag
                        file even if there's no buffer currently open, as long
                        as the current working directory (as returned by
                        |:cd|) is inside a known project.
                        This is useful if you want Gutentags to generate the
                        tag file right after opening Vim.
                        Defaults to 0.

More can be found here: https://github.com/ludovicchabant/vim-gutentags/blob/master/doc/gutentags.txt