bash-completion
bash-completion copied to clipboard
clang: new completion
This patch adds support for autocompleting clang flags, by using its new --autocomplete API to get all possible flags and their values dynamically.
Works with clang 5.0 released in August 23 and will fall back to the default completion for older clang versions.
(The fish maintainers are also using this new API here: fish-shell/fish-shell#4174 )
@scop Since this clang --autocomplete API is implemented in clang 5.0, Ubuntu 14.04 doesn't support this newest clang version. What do you think I can do about this?
Travis has the LLVM repository setup, so I think we could get the most recent clang from there for completion testing.
@scop Could you review?
Have you suggested including this with clang, instead of in bash-completion? That would solve any versioning issues, and the completion could just assume that the corresponding clang is installed etc.
We already included this script in clang, as below. But we wanted to make this completion default on bash.
https://github.com/llvm-mirror/clang/blob/master/utils/bash-autocomplete.sh
I'm not sure if I understand correctly what you mean by "make this completion default on bash". But I guess what you're after is that it gets installed properly and auto-enabled as appropriate -- if so, you should be just installing it properly along with the rest of clang. There should be no reason to ship another copy with bash-completion; the duplication just causes problems and increases maintenance.
We have support files for cmake and instructions how to use them in README.md, so proper install of the completion file should be straightforward. Something like this (untested) should work, feel free to submit it to clang upstream for me:
https://github.com/scop/clang/tree/bash-completion-install https://github.com/scop/clang/commit/ceb95f6a46f5841bff97b961c54c0730270931e9.patch
@scop Hmm, I'm not sure how this would for example work on OS X. Because clang there is provided by Apple, but bash-completion scripts by the brew maintainers. Any idea how to solve this? Because I fear that this will end with the brew maintainers patching in this completion on their own.