Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure descriptions format #417

Closed
disrupted opened this issue May 24, 2021 · 8 comments
Closed

Configure descriptions format #417

disrupted opened this issue May 24, 2021 · 8 comments
Labels

Comments

@disrupted
Copy link

disrupted commented May 24, 2021

First of all let me say I am totally amazed by carapace. I discovered it thanks to your PR cli/cli#2728 and was blown away when I discovered what it can do.

One minor thing I'd like to ask/request is how to change the format used for the descriptions?

In my ZSH setup using the standard completion source (e.g. for gh) the descriptions are separated by --, which I like.

before

After loading carapace (source <(carapace gh zsh)) the descriptions change to this format (using parentheses)

after

If possible I'd like to keep my existing description format so that it stays uniform across different commands.

Here's my zshrc for reference: https://github.com/disrupted/dotfiles/blob/4957c485b2b7bf2a73af9393bf8d599fd6afbfec/.zshrc

@rsteube rsteube added the zsh label May 24, 2021
@rsteube
Copy link
Member

rsteube commented May 24, 2021

I agree the descriptions format should be consistent to the other commands and as a longterm zsh user (before switching to elvish) i would expect the same.
Actually this was the case when carapace was still using the _arguments function.

As far as i remember the main reasons i had to change it to the underlying command compadd were:

  • A missing flag.
    I think it was the one to configure if space is added or not (which is needed for multiparts completion).
  • Issues regarding escaping special characters.
    : was an issue as it is used as divider as well as some others that broke the completion.

Though it was also quite a pain to get it working correctly compadd is a bit simpler as you just reference two arrays (values and descriptions).

I just had another look at it and using compdescribe might be possible, but worst case the _compdescribe script would need to be altered a bit.

So at the moment it does not support the -- style (though i really want it to).
And it might take a while until i tackle this issue since so far i was rather content with how well it is working so i could focus on other problems first.
It's possible that it is not that hard to fix but in my experience there are a lot of edge cases to consider that easily break the completion.

@rsteube
Copy link
Member

rsteube commented May 24, 2021

I think i see another reason why i deviated from the _arguments/_describe functions. It seems with them you can only set the description whereas in compadd you set the display value.
This is relevant for the multiparts completion as you don't want to display the whole prefix, e.g. with file path completion:
Instead of:

/my/folder/s<TAB>
# /my/folder/subfolder1
# /my/folder/subfolder2
/my/folder/s<TAB>
# subfolder1
# subfolder2

@rsteube
Copy link
Member

rsteube commented May 24, 2021

@disrupted I set the listing to one-per-line and altered the display values so that they at least mimic the standard behaviour.
This doesn't put values with the same description side-by-side though (e.g. shorthand and longhand flag -f --files -- description).
compadd can be called with a group flag so each line in the zsh completion might actually just be a separate group of horiziontal completion but i have to look more into that.

Btw. i tried out your config in a container and due to the separate completion menu prefilling the search bar with the current word it interferes a bit with the multiparts completion from the second segment onward as values are filtered. Works fine, but the search bar must be cleared each time.

@disrupted
Copy link
Author

disrupted commented May 24, 2021

Brilliant! Thank you for getting on it so quickly. It works exactly as I hoped now.

Btw. i tried out your config in a container and due to the separate completion menu prefilling the search bar with the current word it interferes a bit with the multiparts completion from the second segment onward as values are filtered. Works fine, but the search bar must be cleared each time.

Could you give me an example what you mean by multiparts completion? So far I haven't encountered any issues but I also just started using it. I basically use it the same way I did with the builtin ZSH tab-completion for gh except now it dynamically queries issues/PRs/etc which is excellent!

@rsteube
Copy link
Member

rsteube commented May 24, 2021

Try gh issue list --label bug,<TAB> it will prefill the search bar with bug, and thus filter the values.
At first i was thinking that something isn't working but it's rather fine.

@disrupted
Copy link
Author

thanks for the explanation, I see what you mean. Tbh I wouldn't even have known that this is supposed to work. Do you happen to know if this can be fixed somehow? otherwise I guess I am okay with it anyways

@rsteube
Copy link
Member

rsteube commented May 25, 2021

I think it's rather a feature from the plugin:
https://github.com/disrupted/dotfiles/blob/4957c485b2b7bf2a73af9393bf8d599fd6afbfec/.zshrc#L114

prefix might be an alternative, but that depends on your preferences:
https://github.com/Aloxaf/fzf-tab/wiki/Configuration#query-string

@rsteube rsteube closed this as completed May 26, 2021
@disrupted
Copy link
Author

In the unlikely event anyone comes across this I solved it by setting

zstyle ':fzf-tab:*' query-string prefix first

obreitwi added a commit to obreitwi/dot_zsh that referenced this issue Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants