nix-zsh-completions icon indicating copy to clipboard operation
nix-zsh-completions copied to clipboard

Add option value completion

Open hedning opened this issue 6 years ago • 0 comments

There's one pretty straightforward thing to do here: provide reasonable completion for things like builders and stores.

Unfortunately nix --help-config dosen't report the type of an option. That means we'll have to build a manual lookup table for known options (with sane fallback).

We also want to at least recognize the short form of options (nix build --no-sandbox etc.). Thankfully we can infer boolean types from descriptions starting with Whether . Meaning we're able to determine if a short option takes an argument or not automatically. That way we won't mistake an option argument as a normal argument (eg. nix-build --foo bar -A baz).

I feel that completing all the options by default is a bad idea, as there's a ton of them which makes it hard to pick out the important stuff. We do something similar with nix-store completing everything only after we've started to type --*: https://github.com/spwhitt/nix-zsh-completions/blob/master/_nix-store#L134. Though I'm not sure if it's easy to make a general solution for this, and since we're dealing with optargs we'll have to provide the necessary information to _arguments when necessary.

hedning avatar Apr 30 '19 15:04 hedning