-
Notifications
You must be signed in to change notification settings - Fork 202
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 tab completion capabilities #721
Conversation
This test ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work @jlprat, nevermind the CI errors, I'll fix them myself. Thanks for this high-quality solution, generators are always the way to go 😉
You're welcome @jvican ! What about the installation scripts? Will the new file under |
They won't be magically copied, you need to modify two files:
One question that comes to mind: can we avoid generating this file and instead let the server reply to the fish's autocompletion engine? The following SO question has two relevant answers that hint that this is possible. One reason why I prefer this approach is because it's likely that this file will go outdated. |
Without being an expert in fish, letting the server respond will only work if the bloop server is running when the shell starts. The main probles comes with the flag completion, where we need to have 1 I also didn't line this solution, but as it's being used already to keep the docs up, I guessed it won't be outdated that easily. PS: you forgot the SO link 😉 |
I would favor talking to the server to get the autocompletions directly since that's the way bash and zsh autocompletions work in bloop now. It's true that autocompletions won't work if the server is not running, but that's OK since you can do nothing when the server is down (the best way to ensure that this doesn't happen is that you have brew services/systemd enabled in your system). |
If this is an acceptable case, then I can rewrite it to use the autocompletions directly from server. PR update will come during next days. |
Is this a fish-specific limitation? I've never had such issues with zsh/bash.
Thanks Josep! |
If I understand There are conditionals on the The main problem is that in |
@@ -62,7 +62,7 @@ | |||
help="Tell the location of the ivy home.") | |||
parser.add_argument( | |||
'--bloop-home', | |||
help="Tell the location of the ivy home.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed a typo here
|
||
|
||
# Nothing has been provided yet. Complete with commands | ||
complete -c bloop -f -n "__assert_args_count 0" -a '(_commands)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will recover if bloop server
is not running and then started.
complete -c bloop -f -n "__assert_args_count 0" -a '(_commands)' | ||
|
||
# Only a project command has been provided | ||
complete -c bloop -f -n "__assert_args_count 1; and __fish_seen_subcommand_from_project_commands" -a '(_projects)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will recover if bloop server
is not running and then started.
set -l flags (_flags_for_command $cmd) | ||
for flag in $flags | ||
set -l parsed (string split '#' $flag) | ||
if test -n $parsed[1] -a -n $parsed[2] -a -n $parsed[3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will not recover if bloop server
is not running and then started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jlprat Thanks! This looks great, I love that we reuse the same machinery than zsh and bash do. I've just left one comment.
Can you rebase the PR so that I can merge after the comment is addressed?
#### Fish completions | ||
|
||
To get the command line completions with fish shell, navigate to your local completion location (e.g.: `~/.config/fish/completions`) | ||
and create a symlink to the file provided in the Bloop distribution: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we mention here what to do if the bloop server is not running and how to get the fish completions to work after the user manually starts the server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, makes sense to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, whenever you make the change, please rebase the PR so that i can merge it right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change done, and rebased against master.
ee9feb3
to
b5c8651
Compare
Refs: scalacenter#695 Adds documentation on how to install Adds documentation for developers when changing commands Provides a file to generate tab completions for fish Disclaimer on the approach: fish tab completions take a more descriptive approach than the one Bash or zsh have. The common way to write such tab completion files for fish is usually by listing all possible sub-commands and flags in such files.
Adds fish format for CliParsers
Remove echo that was used for debugging purposes
b5c8651
to
f100f84
Compare
🙇 |
Refs: #695
Adds documentation on how to install
Adds documentation for developers when changing commands
Provides a file to generate tab completions for
fish
Disclaimer on the approach:
fish
tab completions take a more descriptive approach than the oneBash
orzsh
have. The common way to write such tab completion files forfish
is usually by listing all possible sub-commands and flags in such files.I'm not sure if some other areas would need to be touched, like the installation script for example