bazelbuild / vscode-bazel

Bazel support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel
Apache License 2.0
232 stars 76 forks source link

Feature request: shortcut to jump to BUILD or BUILD.bazel file #353

Open jiawen opened 4 months ago

jiawen commented 4 months ago

I primarily work on a mixed C++ and Python monorepo. I frequently find myself editing say a .cc file and wanting to jump to its corresponding BUILD file (in the same package). Is there a command to which I can assign a shortcut?

catskul commented 4 months ago

I found this because I was just going to open the same feature request!

Not sure if I should open a separate request, but the inverse would be nice too, where you could "goto" source file from the BUILD.bazel file.

cameron-martin commented 4 months ago

Seems similar to https://github.com/bazelbuild/vscode-bazel/issues/178, but with the added bonus of jumping to the target, not just the nearest BUILD file.

jiawen commented 4 months ago

Oops you're right!

catskul commented 4 months ago

Perhaps we should leave them both open until we get an official response from the core developers? They're slightly different requests. Not sure if that matters.

kchodorow commented 3 months ago

I'd be interested in implementing both of these, if that's okay with the maintainers.

vogelsgesang commented 3 months ago

Thanks for that offer and for your first Pull Request, @kchodorow 🚀

I already replied in the pull request regarding the "go from a BUILD file to the referenced source file" functionality. Regarding the "go from a source code file to corresponding BUILD target", a pull request would also be very welcome 🙂

On a related note: I think having a "keep focus in sync with active editor" option for the Bazel Build Targets tree view would be pretty neat. I.e., whenever the currently active file in the editor is changed, the tree view is focused on the package of the currently edited file. Not sure if this is even possible with the APIs exposed by Visual Studio Code, though...

kchodorow commented 3 months ago

Thanks! Source code -> build target is in progress (although probably dependent on the same StarLark/bazel query factors as the first PR).

On a related note: I think having a "keep focus in sync with active editor" option for the Bazel Build Targets tree view would be pretty neat. I.e., whenever the currently active file in the editor is changed, the tree view is focused on the package of the currently edited file. Not sure if this is even possible with the APIs exposed by Visual Studio Code, though...

Interesting, that sounds useful! I'll take a look at what's available and let you know.