Use bazel query to provide completion on target names
This CL enhances the build commands by automatically inferring the name of the target from the current buffer. If multiple targets match, completion is provided with the list.
This also changes the commands to run from the root of the workspace with a cd
If the current buffer is
- A file, bazel query is used to figure out the name of the target that the file is a src of.
- A directory (dired mode), the list of targets in the package is provided with default :all
- A BUILD file, the targets in the package as well.
Note that I did not add unit tests. I did check locally on all three files that it works. This PR for your consideration. I'll be running this on my box for a while. Happy to move to a branch if you prefer to work that way (let me know0.
Some further improvements are possible for the future:
- Adding an option to disable this might be useful, as it can be a little slow.
- When computing the completion list over a file, it may be a good idea to actually fetch it for the enclosing package, so that if the user wants to edit it there's completion from packages nearby.
- If a single target matches the file, maybe the command should just run. Using a prefix argument to allow the user to edit the target before running, perhaps.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
:memo: Please visit https://cla.developers.google.com/ to sign.
Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.
What to do if you already signed the CLA
Individual signers
- It's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
Corporate signers
- Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to go/cla#troubleshoot (Public version).
- The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.
- The email used to register you as an authorized contributor must also be attached to your GitHub account.
ℹ️ Googlers: Go here for more info.
@googlebot I signed it!
This CL enhances the build commands by automatically inferring the name of the target from the current buffer. If multiple targets match, completion is provided with the list.
This also changes the commands to run from the root of the workspace with a cd before the command name.
Would you mind splitting up these two changes into separate PRs? They seem pretty unrelated to each other.