bash-completion icon indicating copy to clipboard operation
bash-completion copied to clipboard

clang: new completion

Open yamaguchi1024 opened this issue 7 years ago • 7 comments

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 )

yamaguchi1024 avatar Aug 16 '17 07:08 yamaguchi1024

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

yamaguchi1024 avatar Aug 26 '17 03:08 yamaguchi1024

Travis has the LLVM repository setup, so I think we could get the most recent clang from there for completion testing.

Teemperor avatar Sep 08 '17 09:09 Teemperor

@scop Could you review?

yamaguchi1024 avatar Sep 17 '17 03:09 yamaguchi1024

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.

scop avatar Sep 17 '17 05:09 scop

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

yamaguchi1024 avatar Sep 17 '17 05:09 yamaguchi1024

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 avatar Sep 17 '17 16:09 scop

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

Teemperor avatar Sep 17 '17 17:09 Teemperor