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 autocompletion with Bash and zsh #353

Merged
merged 15 commits into from
Mar 14, 2018
Merged

Add autocompletion with Bash and zsh #353

merged 15 commits into from
Mar 14, 2018

Conversation

Duhemm
Copy link
Collaborator

@Duhemm Duhemm commented Mar 14, 2018

This adds a new command completion to bloop that takes care of providing autocompletion suggestions. The output is configured with --format, so that it can be understood by different autocompletion engines.

The suggestions for autocompletion depend on the context where they are applied: For instance, after a command, Bloop will suggest project names. If the command is run and the flag is --main, Bloop will propose main classes.

Currently Bloop will not suggest test names in (test, --filter) because extracting the test names requires some refactoring that I've undertaken in my WIP to support Scala Native. I'll fix that later.

The homebrew formula installs both autocompletions for Bash and zsh.

@Duhemm Duhemm added enhancement feature cli install workflow Anything that has to do with the developer workflow. ergonomics Any change that affects developer ergonomics and the easiness of use of bloop. labels Mar 14, 2018
@valencik
Copy link
Contributor

WOW! This is wicked

Copy link
Contributor

@jvican jvican left a comment

Choose a reason for hiding this comment

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

🚀 Perfect PR, I only have one suggestion!

@@ -34,6 +34,14 @@ object Commands {
@Recurse cliOptions: CliOptions = CliOptions.default
) extends RawCommand

case class Completion(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we call this autocompletion so that completion doesn't conflict with compile?

Copy link
Contributor

@olafurpg olafurpg Mar 14, 2018

Choose a reason for hiding this comment

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

I was gonna suggest the same, ideally there should be no conflicting tasks with test and compile to make c<TAB> => compile and t<TAB> => test completion work

@Duhemm
Copy link
Collaborator Author

Duhemm commented Mar 14, 2018

This is my first feature written 100% with Bloop 😄

This allows to have bloop suggest completion when doing for instance:

  - bloop run frontend --main <tab>
    will suggest `bloop.Bloop`, bloop.Cli` and `bloop.Server`

  - bloop test frontend --filter <tab>
    should suggest `bloop.nailgun.BasicNailgunSpec` (and more), but this
    is not finished at the moment (pending some refactoring of test
    discovery)
This will make it easier to generate auto completion for them
@jvican
Copy link
Contributor

jvican commented Mar 14, 2018

I've just tried this out, it's awesome.

Someone, in the future, should check whether we abide by the rules described in the zsh completions bible or not. https://github.com/zsh-users/zsh/blob/master/Etc/completion-style-guide

This is not a blocker for now, it works.

I added the following to my ~/.zshrc:

fpath=(/data/rw/code/scala/loop/etc/zsh $fpath)
autoload -U _bloop
compdef _bloop bloop

@jvican jvican merged commit 10bd93a into master Mar 14, 2018
@olafurpg
Copy link
Contributor

JUST RELEASE ALREADY WILL YA 😸

@jvican
Copy link
Contributor

jvican commented Mar 14, 2018

Waiting on a PR to update the docs and update the python script and we release M7 folks! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli enhancement ergonomics Any change that affects developer ergonomics and the easiness of use of bloop. feature install workflow Anything that has to do with the developer workflow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants