vim-gutentags icon indicating copy to clipboard operation
vim-gutentags copied to clipboard

please support the usage of `vim -t symbol`

Open chinyu0704 opened this issue 2 years ago • 9 comments

hi, please support the usage of vim -t symbol, some people are used to it. For now when I use this pattern, I get

image

so I check the ctag database, and the new tag file generated by gutentags(not in current dir) was not there image

chinyu0704 avatar Jul 14 '22 14:07 chinyu0704

I've found a workaround for this from here. You can add this to your .vimrc: execute 'set tags+='.substitute(glob(g:gutentags_cache_dir .. '/*tags'), "\n", ',', 'g').

This would add every tags file ending with tags in your gutentags_cache_dir to the tags variable. Unfortunately, this would remove the feature of only adding the tags file for the current project, but this issue would have to be fixed within the script itself.

jdholtz avatar Nov 13 '22 06:11 jdholtz

this works, thanks @jdholtz

chinyu0704 avatar Nov 14 '22 01:11 chinyu0704

Right now gutentags tries to stay out of the way until it's needed, i.e. when you open a file that belongs to a project that needs tag support. Supporting the -t argument would require gutentags to always initialize and scan stuff on startup -- I don't see any obvious way to figure that -t was passed (surprisingly enough, argc() and argv() come out empty for that...). I'm not ready to refactor the plugin to work that way, but it's worth keeping in mind.

ludovicchabant avatar Nov 27 '22 21:11 ludovicchabant

You can find if -t is passed as a flag by doing match(v:argv, '^-t') >= 0.

However, when I tried implementing this, the tags variable gets set correctly, but it seems like vim searches for the tag before the plugin has initialized, because the tag is still not found (even though doing :tag {tag} in the buffer does work).

Let me know if you have any solutions to this (unless this is what you mean by not wanting to initialize the tags unless it is necessary) and I can submit a PR for it.

jdholtz avatar Nov 29 '22 03:11 jdholtz

I am myself a user of vim -t and it works just fine with gutentags and I guess the reason is because I use this option ? :

let g:gutentags_project_root = ['Makefile']

I always have a tags file at the root of my project and it works well

cassepipe avatar Dec 15 '22 13:12 cassepipe

@cassepipe this problem occurs when the tags file is not in the current directory that vim -t is executed in (when using theg:gutentags_cache_dir option to store tags elsewhere besides the project root)

jdholtz avatar Dec 15 '22 21:12 jdholtz

So the problem comes from vim not being able to find tags with the -t option when the tags file is not in the current directory, right ? What about changing g:gutentags_cache_dir to the current directory ?

cassepipe avatar Dec 15 '22 23:12 cassepipe

Yes, but many people want their tags stored in a certain directory, not the project root. Users shouldn’t be limited on how they can use this plugin if they want to use the -t flag with vim.

jdholtz avatar Dec 16 '22 02:12 jdholtz

Hey @ludovicchabant, any updates after my comment here ?

jdholtz avatar Jan 12 '23 00:01 jdholtz