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

please support the usage of vim -t symbol #331

Open
chinyu0704 opened this issue Jul 14, 2022 · 9 comments
Open

please support the usage of vim -t symbol #331

chinyu0704 opened this issue Jul 14, 2022 · 9 comments

Comments

@chinyu0704
Copy link

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

@jdholtz
Copy link

jdholtz commented Nov 13, 2022

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.

@chinyu0704
Copy link
Author

this works, thanks @jdholtz

@ludovicchabant
Copy link
Owner

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.

@jdholtz
Copy link

jdholtz commented Nov 29, 2022

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.

@cassepipe
Copy link

cassepipe commented Dec 15, 2022

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

@jdholtz
Copy link

jdholtz commented Dec 15, 2022

@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)

@cassepipe
Copy link

cassepipe commented Dec 15, 2022

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 ?

@jdholtz
Copy link

jdholtz commented Dec 16, 2022

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
Copy link

jdholtz commented Jan 12, 2023

Hey @ludovicchabant, any updates after my comment here ?

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

4 participants