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

Ship shell completion files #1975

Closed
diktomat opened this issue Apr 6, 2022 · 3 comments
Closed

Ship shell completion files #1975

diktomat opened this issue Apr 6, 2022 · 3 comments
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@diktomat
Copy link
Contributor

diktomat commented Apr 6, 2022

Helix should ship with completion files for the hx command for the most widely used shells (bash, zsh, fish?). I already got it ready for fish and will do bash and zsh as well, but it should first be discussed which way to go:

  • premade files to install into vendor completions directory
    • no action required for user
    • pkg-config --variable completionsdir fish, don't know for bash/zsh as they're not known to pkg-config on macOS
  • a command line option to build completions for the specified shell
    • to be used like hx --generate-completion fish > ~/.config/fish/completions/hx.fish
    • could include --health language completion for user-added langs)
  • your better idea here ;)
@diktomat diktomat added the C-enhancement Category: Improvements label Apr 6, 2022
@the-mikedavis the-mikedavis added the A-helix-term Area: Helix term improvements label Apr 6, 2022
@the-mikedavis
Copy link
Member

I would prefer the --generate-completion approach so anyone with custom language configuration can regenerate their completion to reflect what languages they have configured.

@diktomat
Copy link
Contributor Author

diktomat commented Apr 6, 2022

As the args are hardcoded (i.e. no argument parser lib) in helix_term#args() and #main_impl(), I think the straightforward approach to this would be to do the same: have static templates for each shell and just dynamically insert the languages.

Another way I just thought of would be to grab the languages out of hx --health in the completion script itself, something like this (fish):

set -l langs (hx --health |tail -n '+7' |awk '{print $1}' |sed 's/\x1b\[[0-9;]*m//g')
complete -c hx -l health -x -a "$langs" -d "foo description"

That way no additional generation code is needed, keeping source clean.

@diktomat
Copy link
Contributor Author

diktomat commented Aug 2, 2022

As this was merged weeks ago and no need/talk of changing or enhancing the current implementation, gonna close this..

@diktomat diktomat closed this as completed Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

2 participants