ludovicchabant / vim-gutentags

A Vim plugin that manages your tag files
https://bolt80.com/gutentags/
MIT License
2.3k stars 175 forks source link

Improve compatibility with ctags like programs #257

Closed awlayton closed 2 years ago

awlayton commented 4 years ago

These changes are for improving using gutentags with other programs like ctags. Specifically when I was trying to use ctags-shim and was getting the error ctags job failed, returned: 1.

I figured out it was due to the way gutentags was supplying arguments to the executable.

I have made the following changes that produce the desired behavior with ctags-shim while having the same behavior as before with ctags:

I intended to update update_tags.cmd too, but I do not know batch files very well and have no setup to test my changes with. So this PR working for Linux but not windows still needs a change.

ludovicchabant commented 4 years ago

Changing --recurse seems OK, but inlining a potentially very long options file would make it difficult to troubleshoot things, and might even expose us to weird bugs due to command line parsing, so I'd rather not do that. It sounds it simpler to have ctags-shim forward --options, no?

arkku commented 4 years ago

I would suggest introducing a new flag which inlines the options. That is, -o file would pass --options=file whereas (e.g.) -i file would inline it as per this pull request. Then -i could always be used for the file containing just --recurse, whereas the -o vs -i could be configurable for the project options file (e.g., let g:gutentags_inline_options=1). And if this is not needed on Windows (or no-one here knows how to do it), just make -i and -o synonyms on Windows for the time being…

ludovicchabant commented 4 years ago

What the point of inlining the options? If it's for avoiding sending --options to a ctags program that doesn't support it, sooner or later you'll send another option it doesn't support and you'll be stuck with the same problem. Arguably, any program masquerading as ctags should support --options anyway. And it's relatively easy to make a script that swallows unwanted options if you can't add support for those options in the ctags program.

This is especially important since I'm currently considering sending no options at all anymore, and instead having vim generate a temp options file to pass to ctags. The goal here being to stop getting all those endless bugs about badly quoted arguments and spaces in paths and so on that mostly come from shell syntax problems.

arkku commented 4 years ago

@ludovicchabant To be honest, I don't really understand the reasoning for inlining given in this pull request originally, but I suggested doing it with a separate -i option because that would easily solve both this request (for what it's worth!), and the fact that currently the script silently ignores all but the last -o option (and there are cases where it will currently be given two -o options, causing the first to be silently missed).

However, if you are going to generate a temporary options file and pass only one -o option, then that also solves the latter concern, and I'm entirely fine with that.

ludovicchabant commented 2 years ago

I'm closing this, argument parsing is crazy enough already as it is. Thanks everybody who chimed in.