Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get gutentags_file_list_command to work #208

Closed
trevordmiller opened this issue Oct 29, 2018 · 7 comments
Closed

How to get gutentags_file_list_command to work #208

trevordmiller opened this issue Oct 29, 2018 · 7 comments

Comments

@trevordmiller
Copy link

trevordmiller commented Oct 29, 2018

First, thanks so much for a wonderful plugin! It is very useful and I really appreciate your work on it!

I'm trying to figure out a better system for ignoring directories/files from ctags. Up to this point, I've been using Universal Ctags with a .ctags.d/config.ctags config that looks like:

# GENERAL
--exclude=.git
--exclude=.DS_Store

# JAVASCRIPT
--exclude=node_modules
--exclude=package-lock.json
...

However, many of the projects I work on have specific compiled output that I'd like to ignore as well so this file keeps getting longer. I would like to instead rely on my ag (silver searcher) file list, since these are the source files I actually care about. After reading through a few other issues like #136, I've tried setting let g:gutentags_file_list_command = 'ag -l', but this leads to Gutentags hanging with an empty tags.files.

I've tried this with multiple repos with the same result, so I don't think it is a problem specific to my project. I enabled let g:gutentags_trace = 1 and get the following:

Default setup

With a default setup, without Gutentags specific config, I get a tags output and everything works.

screen shot 2018-10-29 at 2 20 18 pm

After adding let g:gutentags_file_list_command = 'ag -l':

gutentags: Scanning buffer '/Users/trevordmiller/repos/dotfiles/index' for gutentags setup...
gutentags: No specific project type.
gutentags: Setting gutentags for buffer '/Users/trevordmiller/repos/dotfiles/index'
gutentags: Generating missing tags file: /Users/trevordmiller/repos/dotfiles/tags
gutentags: Running: ['/Users/trevordmiller/.vim/plugged/vim-gutentags/plat/unix/update_tags.sh', '-e', 'ctags', '-t', 'tags', '-p', '.', '-L', 'ag -l', '-l', 'tags.log']
gutentags: 'Locking tags file...'

It hangs indefinitely on Locking tags file..., never outputting a ctags file.

The output of ag -l is a small list of source files, as I would expect. So it seems there may be a problem with the Gutentags output of

image

vs

image

once let g:gutentags_file_list_command = '{command}' is added?

@trevordmiller
Copy link
Author

trevordmiller commented Oct 30, 2018

Somewhat related: universal-ctags/ctags#218

@ludovicchabant
Copy link
Owner

ludovicchabant commented Nov 4, 2018

Hi!
Have you tried running that update_tags.sh command line by hand to see if it outputs anything useful before hanging? You can also inspect the tags.log file that it left behind for any other clues.
Also, are you using a global tags cache (g:gutentags_cache_dir) or are you leaving tags files in the project roots?

@trevordmiller
Copy link
Author

trevordmiller commented Nov 6, 2018

@ludovicchabant Thanks for your help!

I'm using everything else with default settings. So I am leaving tags files in the project roots. I don't have any other Gutentags or ctags configuration, everything is defaults other than turning on g:gutentags_file_list_command and g:gutentags_trace.

So to be clear: everything works by default. Once I add the following to my .vimrc:

let g:gutentags_file_list_command = 'ag -l'
let g:gutentags_trace = 1

Then I delete the project tags, and open a buffer for it to reindex, I hit the Locking tags file... that hangs. At this point there is no tags.log file, only a tags.lock with 7994 and an empty tags.files.

I did also try running /Users/trevordmiller/.vim/plugged/vim-gutentags/plat/unix/update_tags.sh -e ctags -t tags -p . -L 'ag -l' -l tags.log (I'm not sure if that is the correct syntax?), and it gives this output:

Locking tags file...
Running ctags on whole project
ctags -f "tags.temp"  -L tags.files ""
ctags: Warning: cannot open input file "" : No such file or directory
Replacing tags file
mv -f "tags.temp" "tags"
Unlocking tags file...
Done.

There is a tags file generated in the project root when I ran it manually like this, but the tags has files in it that are not in ag -l.

@ludovicchabant
Copy link
Owner

Mmmh that's weird... I just pushed some fixes to the update.tags.sh script so you can give that a try (for instance it will print a message about running ag if it gets to that, and it also fixes the problem with that warning message you got from ctags).

@trevordmiller
Copy link
Author

@ludovicchabant I updated to latest vim-gutentags. Once I add the two lines mentioned to my .vimrc and delete the project tags file, I am still getting the hanging output with a tags.lock with 36046 and an empty tags.files when I open the first buffer:

"~/repos/dotfiles/files/.vimrc" 86L, 1992C
gutentags: Scanning buffer '/Users/trevordmiller/repos/dotfiles/files/.vimrc' for gutentags setup...
gutentags: No specific project type.
gutentags: Setting gutentags for buffer '/Users/trevordmiller/repos/dotfiles/files/.vimrc'
gutentags: Generating missing tags file: /Users/trevordmiller/repos/dotfiles/tags
gutentags: Wildignore options file is up to date.
gutentags: Running: ['/Users/trevordmiller/.vim/plugged/vim-gutentags/plat/unix/update_tags.sh', '-e', 'ctags', '-t', 'tags', '-p', '.', '-L', 'ag -l', '-l', 'tags.log']
gutentags: [job output]: 'eval ag -l > "tags.files"'

If I run /Users/trevordmiller/.vim/plugged/vim-gutentags/plat/unix/update_tags.sh -e ctags -t tags -p . -L 'ag -l' -l tags.log, I get this output:

Locking tags file...
Running file list command
eval ag -l > "tags.files"
Running ctags on whole project
ctags -f "tags.temp"  -L tags.files
Replacing tags file
mv -f "tags.temp" "tags"
Unlocking tags file...
Done.

And the same "There is a tags file generated in the project root when I ran it manually like this, but the tags has files in it that are not in ag -l."

@trevordmiller
Copy link
Author

I'll close this for now since it seems I am the only one who has ran into this.

@faisal-shah
Copy link

I have the identical problem. Running update_tags.sh works like a charm:

$ ~/.vim/plugged/vim-gutentags/plat/unix/update_tags.sh -e ctags -t tags -p . -L 'ag -l' -l tags.log
Locking tags file...
Running file list command
eval ag -l > "tags.files"
Running ctags on whole project
ctags -f "tags.temp" -L "tags.files"
Replacing tags file
mv -f "tags.temp" "tags"
Unlocking tags file...
Done.

However, in Vim it doesn't work. Below is the :messages output:

gutentags: Scanning buffer '/home/dev/repos/project/main.c' for gutentags setup...
gutentags: No specific project type.
gutentags: Setting gutentags for buffer '/home/dev/repos/project/main.c'

gutentags: Generating missing tags file: /home/dev/repos/project/tags
gutentags: Wildignore options file is up to date.
gutentags: Running: ['/home/dev/.vim/plugged/vim-gutentags/plat/unix/update_tags.sh', '-e', 'ctags', '-t', 'tag
s', '-p', '.', '-L', 'ag -l', '-l', 'tags.log']
gutentags: In: /home/dev/repos/project/speed
gutentags: [job stdout]: 'Locking tags file...'
gutentags: [job stdout]: 'Running file list command'
gutentags: [job stdout]: 'eval ag -l > "tags.files"'

... and then nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants