This is not a bug report.
It is documented behaviour that g:gutentags_generate_on_new = 1 causes vim to generate a new ctags file for a project when starting vim. This makes sense, as files from external dependencies could have been updated (using tools like composer, pip, go get etc) and the easiest way for vim-gutentags to pick up those changes is to create a new ctags file, from scratch.
I switch a lot between vim and my shell. Often is suspend vim to the background with ctrl+z, but often I also close vim completely. Running a few commands, then opening it again. This way of working causes vim-gutentags to always create that new ctags file.
Similar to the behaviour of gnu-make I have added the following code to plat/unix/update_tags.sh
diff --git a/plat/unix/update_tags.sh b/plat/unix/update_tags.sh
index 9c1a24b..6d6f729 100755
--- a/plat/unix/update_tags.sh
+++ b/plat/unix/update_tags.sh
@@ -107,6 +107,11 @@ if [ -f "$TAGS_FILE" ]; then
fi
if [ $INDEX_WHOLE_PROJECT -eq 1 ]; then
+ if ! fd --changed-after="$(stat ${TAGS_FILE} --format='@%Y')" --type=file --no-ignore-vcs --quiet; then
+ echo "None of the source files are newer than ${TAGS_FILE}. No need to update anything."
+ exit 0
+ fi
+
if [ -n "${FILE_LIST_CMD}" ]; then
if [ "${PROJECT_ROOT}" = "." ] || [ $FILE_LIST_CMD_IS_ABSOLUTE -eq 1 ]; then
echo "Running file list command"
What it does:
- It first gets the modified unix timestamp of
$TAGS_FILE
- Then it uses
fd to find any source file in the project that is more recent that $TAGS_FILE.
- Using
--quiet, fd stops when at least one file matches.
This way, you can open/close vim many times, and a ctags file will not be generated all the time.
I hope this idea could lead to a feature addition to this awesome library.
This is not a bug report.
It is documented behaviour that
g:gutentags_generate_on_new = 1causes vim to generate a new ctags file for a project when starting vim. This makes sense, as files from external dependencies could have been updated (using tools likecomposer,pip,go getetc) and the easiest way forvim-gutentagsto pick up those changes is to create a new ctags file, from scratch.I switch a lot between vim and my shell. Often is suspend vim to the background with
ctrl+z, but often I also close vim completely. Running a few commands, then opening it again. This way of working causes vim-gutentags to always create that new ctags file.Similar to the behaviour of
gnu-makeI have added the following code toplat/unix/update_tags.shWhat it does:
$TAGS_FILEfdto find any source file in the project that is more recent that$TAGS_FILE.--quiet,fdstops when at least one file matches.This way, you can open/close vim many times, and a ctags file will not be generated all the time.
I hope this idea could lead to a feature addition to this awesome library.