Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: clang completion



On Sat, Jun 30, 2018 at 01:34:02AM -0700, Eitan Adler wrote:
> Hey all,
> 
> I just discovered this feature of clang but unfortunately lack the
> time to properly sort this out:
> 
> http://blog.llvm.org/2017/09/clang-bash-better-auto-completion-is.html'
> 
> ∴clang --autocomplete='-tr'
> -traditional-cpp Enable some traditional CPP emulation
> -trigraphs Process trigraph sequences
> 
> ∴clang --autocomplete='-std=,c++0'
> c++03
> c++0x
> and so on
> 
> It seems easy enough to use. Maybe its time to give clang its own completer?
> gcc might also be thinking of doing something similar
> https://gcc.gnu.org/ml/gcc/2018-04/msg00148.html ?

Proof of concept completer:

#compdef clang

local -a options=(${${${(f)"$(_call_program clang clang --autocomplete=${words[CURRENT]/=/\=,})"}//:/\\:}/$'\t'/:})
compset -P '*='
_describe options options

The issue is I'm not sure what format --autocomplete expects. It seems
to want commas after the first = as in the -std example, but what about
if there's more =s or if there's a comma in an argument?  I didn't find
docs with a quick search nor did I get a response from #llvm. If anyone
knows where --autocomplete docs are, those would be most helpful. I've
avoided reading the bash completer to avoid GPL taint.

I believe there were also concerns that clang cannot be split from gcc
and cc since clang is cc sometimes (for instance on OpenBSD for some
architectures).

- Matthew Martin



Messages sorted by: Reverse Date, Date, Thread, Author