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
Support clang's new shell autocompletion feature #4174
Comments
I'd be willing to do this once I have that version on my machine. Any idea when it's going to be released? Some notes for later:
|
LLVM/clang 5 will release on 23rd of August, but it's really up to your OS-vendor when it arrives on your machine :). If there are some API changes with the --autocomplete flag that can't be worked around from the fish complete script, then we can still influence the API for the script until the 19th of July when clang 5 is tagged (but no promises on this). |
For fish, this would ideally receive the full clang commandline up to the cursor. I.e. we'd just call Also, it would delimit different candidates with newlines, not spaces - this shouldn't break anything for bash either. Also, it would use Support for descriptions would be nice to have - something like None of these are dealbreakers, though. |
Perhaps the clang maintainers would consider shipping the fish completion themselves - it might be worth trying to get it written before the release. |
The autocomplete support has landed in clang 5.0 which will release in two weeks and is currently in testing and available in the LLVM apt repository. We added support for flag descriptions in the format fish wants (separated by The clang unit tests should help with explaining the API. Also ping for @yamaguchi1024 who is the code owner of this cool feature, she maybe has time to answer your questions. @zanchey Shipping this is up to the distribution maintainers, which is quite a large and diverse group of people we would have to get on board for this to work out :/ |
Nice!
There's probably a reason for them that I don't get. Anyway, we can deal with that. |
Use clang/clang++'s own autocompletion support to complete arguments. It is rather convoluted as clang generates autocompletions for a portion of the current token rather than the entire token, e.g. while `--st` will autocomplete to `--std=` (which is fine by fish), `--std=g` will autocomplete to `gnu...` without the leading `--std=` which breaks fish' support for the completion. Additionally, on systems where clang/clang++ is the system compiler (such as FreeBSD), it is very often for users to invoke a newer version of clang/clang++ installed as clang[++]-NN instead of clang. Using a monkey-patched version of `complete -p` to support that without breaking (future) completions for commands like `clang-format`. Closes fish-shell#4174.
Use clang/clang++'s own autocompletion support to complete arguments. It is rather convoluted as clang generates autocompletions for a portion of the current token rather than the entire token, e.g. while `--st` will autocomplete to `--std=` (which is fine by fish), `--std=g` will autocomplete to `gnu...` without the leading `--std=` which breaks fish' support for the completion. Additionally, on systems where clang/clang++ is the system compiler (such as FreeBSD), it is very often for users to invoke a newer version of clang/clang++ installed as clang[++]-NN instead of clang. Using a monkey-patched version of `complete -p` to support that without breaking (future) completions for commands like `clang-format`. Closes fish-shell#4174.
I wonder if there is a good way to try to reasonably dampen down these completions a bit. Type |
The next version of clang will ship with a
--autocomplete
flag that provides a backend for shells to complete all flags that the current clang binary supports. The general idea is that the shell passes the flag it currently wants to complete to clang viaclang --autocomplete=-fsyntax
and then clang prints a list of flags that this completes to:This also works with all the values that the flags take, e.g. in this case return all the stdlibs clang supports in its
-stdlib=libc++
flag:For a better overview, see the clang's bash completion script that illustrates the way the
--autocomplete
flag works: bash-completions.sh.The big advantage is that this allows to have a single shell completion that works with all flags of all future clang versions (even the custom vendor versions from Apple or a self-build clang from trunk!), as the flag just queries the internal option parsing logic of the selected clang binary.
It would be very useful if fish would use this feature and also start calling this flag when trying to complete a clang flag.
The text was updated successfully, but these errors were encountered: