Skip to content

Support clang's new shell autocompletion feature #4174

Closed
@Teemperor

Description

@Teemperor

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:

$./bin/clang --autocomplete=-std
-std-default= -std: -std= -stdlib=

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:

$ ./bin/clang --autocomplete=-stdlib=,
libc++ libstdc++ platform

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions