Comments (11)
I don't really understand everything about what you're looking for so I'll go one step at a time:
-
On the first run, Gutentags runs ctags on the whole project. Most likely in your case the whole project is the whole kernel source, but maybe you actually want one project per architecture? In that case you can change how Gutentags figures out what a "project root" is so that it stops at "arch/foo".
-
After the first run, whenever you edit and save a file, Gutentags will only run ctags on that file, patching the current project's tags file.
from vim-gutentags.
I'm sorry I didn't clearly describe.
For the linux kernel, 'make tags' generate tags based on user's configuration. If I configure the linux for arm architecture, then 'make tags' generates tags for that arch.
And, I expected If there already exists a tags file, the gutentags only update it for a modified/saved source. But it re-generates whole tags file though there already tags file exists.
How I can setup the gutentags?
I hope it udpates the existing tags file for the newly saved source.
Thanks.
from vim-gutentags.
I experienced something similar.
In my project I have an existing "tags" file.
I open a source in vim, then save it.
I expect that only the modified file is reindexed. Instead the whole project is reindexed. ctags version is 5.8. tested on two linux computers with different distributions(arch and mint)
I started the gutentags logging
Locking tags file...
Removing references to: /home/gabi/work/project/a.php
grep -v /home/gabi/work/project/a.php "/home/gabi/work/project/tags" > "/home/gabi/work/project/tags.temp"
Running ctags
ctags -f "/home/gabi/work/project/tags.temp" --options=/home/gabi/dotfiles/.vim/bundle/vim-gutentags/res/ctags.options --exclude=*.dll --exclude=*.o --exclude=*.obj --exclude=*.bak --exclude=*.exe --exclude=*.pyc --exclude=*.jpg --exclude=*.gif --exclude=*.png --exclude=*/CVS/** --append "/home/gabi/work/project/a.php" "/home/gabi/work/project"
ctags: Warning: cannot open input file ""/home/gabi/work/project/a.php"" : No such file or directory
Replacing tags file
mv -f "/home/gabi/work/project/tags.temp" "/home/gabi/work/project/tags"
Unlocking tags file...
Done.
If I remove the project directory path in the ctags command, the behaviour is as expected, only the modified file is indexed. I made a quickhack in update_tags.sh https://gist.github.com/humeniuc/072f39804abf1efd01ab. to compose the ctags command differently if the whole project or only a file is indexed.
I think the "$PROJECT_ROOT" should be skipped in the ctags command ($CTAGS_EXE -f "$TAGS_FILE.temp" $CTAGS_ARGS "$PROJECT_ROOT") when indexing a single file.
from vim-gutentags.
Oh man, @humeniuc you're right, I think. I broke this more than a year ago with commit d8f178b which added support for storing tags
files in a centralized cache directory hidden from sight. Oh well...
Should be fixed with 737279a, although my Mac is dying at the moment so I only have my Windows machine to test the Windows version of the script. Ping me if the Unix script doesn't work.
from vim-gutentags.
Hello.
Sadly the unix version does not work. the log file is:
Locking tags file...
Removing references to: /home/gabi/work/project/a.php
grep -v /home/gabi/work/project/a.php "/home/gabi/work/project/tags" > "/home/gabi/work/project/tags.temp"
Running ctags
ctags -f "/home/gabi/work/project/tags.temp" --options=/home/gabi/dotfiles/.vim/bundle/vim-gutentags/res/ctags.options --exclude=*.dll --exclude=*.o --exclude=*.obj --exclude=*.bak --exclude=*.exe --exclude=*.pyc --exclude=*.jpg --exclude=*.gif --exclude=*.png --exclude=*/CVS/** --append "/home/gabi/work/project/a.php"
ctags: Warning: cannot open input file ""/home/gabi/work/project/a.php"" : No such file or directory
Replacing tags file
mv -f "/home/gabi/work/project/tags.temp" "/home/gabi/work/project/tags"
Unlocking tags file...
Done.
ctags: Warning: cannot open input file ""/home/gabi/work/project/a.php"" : No such file or directory
is caused because of "early" quote of the $UPDATED_SOURCE :
CTAGS_ARGS="$CTAGS_ARGS --append "$UPDATED_SOURCE""
when you run
$CTAGS_EXE -f "$TAGS_FILE.temp" $CTAGS_ARGS
the quotes are passed as literals, and not as tokens to restrict the text inside as a single element.
one fast solution in your case ( you build/compose a string with a command ) is to evaluate the string with the command:
echo "Running ctags"
echo "$CTAGS_EXE -f \"$TAGS_FILE.temp\" $CTAGS_ARGS"
eval "$CTAGS_EXE -f \"$TAGS_FILE.temp\" $CTAGS_ARGS"
but my knowledge of shell scripts are limited, so, I cannot say how safe the "eval" command is.
I know that in bash you can build an array with parameters, and pass that array to ctags as parameters, but there is no such option in posix shell.
An alternative is to pass $UPDATED_SOURCE/$PROJECT_ROOT to the ctags command just when is needed, and overpass the quote problem:
if [ "$REINDEX_FILE" = true ]; then
$CTAGS_EXE -f "$TAGS_FILE.temp" $CTAGS_ARGS --append "$UPDATED_SOURCE"
else
$CTAGS_EXE -f "$TAGS_FILE.temp" $CTAGS_ARGS "$PROJECT_ROOT"
fi
I hope it helps. I will also search for something that fits for your aproach.
Btw, gutentags is one of my favorite plugins, many thanks for it.
from vim-gutentags.
Ah thanks @humeniuc! I spun up a Linux VM to test more and indeed I don't see a way to get around the ugly if
/else
case -- which is probably one of the rare cases where the Windows batch script has one thing that's more elegant than its Unix counterpart :(
Fixed (hopefully for real this time) in 5114b08.
Interestingly enough, I tested with paths with spaces to check all the quoting was working, but the ctags
version I got from apt-get
(Exuberant Ctags 5.9 from 2014) doesn't handle that very well, so I added another option to Gutentags to replace spaces with underscores (this could lead to conflicts but you'd have to be weird to have paths that only differ by one having an underscore and the other having a space... in which case you can disable the setting).
from vim-gutentags.
Hello
Tested on my home linux computer. and works perfectly! Thank you!
I tested with a file with spaces in filenam, but I did not observed any issues. ctags version is a newer one:
Universal Ctags 0.0.0(a1c4a13), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Tomorow, at work, I will test on an original ctags 5.8, and if I will observe any issues, I will post a message.
from vim-gutentags.
I tested with updated gutentags.
It does not help my situation.
As I described, gutentags re-generate tags as soon as I open a file.
I don't save anything, just open a file. The log is:
Locking tags file...
Running ctags on whole project
ctags -f "/data/proj/linux/tags.temp" --options=/home/jason/.vim/bundle/vim-gutentags/res/ctags.options "/data/proj/linux"
...
Note, there is already a tags file. So that, I hope gutentags only update tags when I save a file.
from vim-gutentags.
I tried to debug, and it seems I can use setting below.
let g:gutentags_generate_on_new = 0
With this setting, gutentags does not re-generate tags when I open a file. But it update tags file when I save a file.
Maybe I have to do 'touch tags' for new project, though.
BTW, if the naming 'generate_on_new' is correct, it should check the tags file exists or not.
Currently it always re-generated tags on startup.
from vim-gutentags.
Ok, so yeah, gutentags_generate_on_new
is what you need. When this is set to 1 (the default value), Gutentags will regenerate the whole tags file when you open the first file in a project. This is because, most likely, the tags file is outdated (for instance, you closed Vim, pulled/synced a new version of the codebase, and re-opened Vim). It's also consistent with how all IDEs work.
There's another setting (gutentags_generate_on_missing
) that will generate the tags file if it does not exist.... so when you have the first setting to 0 but the second to 1, it should index the whole project only when you open the first file and the tags file doesn't exist.
The naming is potentially misleading (feel free to suggest other names) but in generate_on_missing
, the "missing" means the tags file is missing. In generate_on_new
, the "new" means you opened a new project.
Sorry for the confusion.
from vim-gutentags.
(if you want to debug all of this, it's in autoload/gutentags.vim
around line 209: https://github.com/ludovicchabant/vim-gutentags/blob/master/autoload/gutentags.vim#L209
from vim-gutentags.
Related Issues (20)
- ERROR: Invalid value for argument cmd and update_gtags.sh is not executable HOT 4
- E117: Unknown function: gutentags#on_vim_leave
- Tags stop working for specific file (path disappears from tags option) after manually setting tags once in that file
- Cannot generate the GTAGS at windows platform HOT 5
- Does it support different ctags file chosen dynamically? HOT 2
- Error code 122 & 139 HOT 7
- please support the usage of `vim -t symbol` HOT 9
- use gtags failed HOT 2
- update_gtags.sh lost execution permission
- How do I use different tag files for different directories of a same workspace HOT 1
- Is there a way to force gutentags to generate only one tag file?
- Keep tags values when opening the quickfix
- nvim 0.9 remove cscope how to HOT 1
- Guttentags does not support any file? HOT 1
- Option to generate tags for open windows or buffers only? HOT 3
- the use of .guttags file HOT 1
- Whitelisting instead of blacklisting HOT 2
- Bug in update_scopedb.cmd file prevents creation of cscope.out.files correctly HOT 1
- Very large tags file generated ( > 10GB) HOT 2
- Plugin don't work if full filename contains open "[" _and_ close "]" square brackets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-gutentags.