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

Add fish shell completions support #538

Merged
merged 8 commits into from
Jun 5, 2024

Conversation

natsukagami
Copy link
Contributor

@natsukagami natsukagami commented May 29, 2024

What's this?

Fish is a modern, popular non-UNIX compatible shell with lots of builtin features.
By supporting Fish we also expand support to Nu, another modern shell with Fish completions compatibility.

The Fish shell completions format is extremely simple (full documentation here).
In general, program-generated fish completion list is just a list of lines, where each item can be followed by an optional description, separated by a tab \t character.

While in general Fish prefers a mostly-static completion list (see the documentation for more details), I think for simplicity's sake it's easier to just keep everything dynamic for now; it also has the upside of supporting non-CaseApp framework conformant projects like scala-cli.

What's included?

  • A fish shell implementation of the completion script.
    • Fish does not require modification of its rc file to load completions (yay modernity!). Instead we only need to install the completions file to the correct place.
      The default install location is $XDG_CONFIG_HOME/fish/completions, but this can be changed with the --output/-o flag.
    • It is also possible to ship this completion file statically when bundling apps, so a completions install command might not even be needed.
  • Re-factoring out completionsInstall and completionsUninstall methods to the object.
    • The main goal is to decouple the two commands from the framework hierarchy. This would help scala-cli for example to just re-use case-app's implementation and not have to duplicate all the logic.
    • I do agree this introduces a few new parameters that looks a bit ugly, feel free to change this to whatever suited.

@Gedochao
Copy link
Collaborator

Gedochao commented Jun 3, 2024

@alexarchambault would you have the time to take a look at this?

... due to an extra field added to PlatformCommandsMethods.CompletionsUninstallOPtions.
@natsukagami
Copy link
Contributor Author

I had to reset mima, since I introduced a new field in the CompletionsUninstallOptions case class. @alexarchambault

Copy link
Owner

@alexarchambault alexarchambault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @natsukagami! (and @Gedochao for the heads'up)

@alexarchambault alexarchambault merged commit d753d92 into alexarchambault:main Jun 5, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants