Feature request: shortcut to jump to BUILD or BUILD.bazel file
jiawen opened this issue ยท 7 comments
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?
- Bonus points if we can jump to the "closest" target that has the current file in
srcs
orhdrs
. - Extra bonus points if there is a command to "jump to next target that has this file (the last focused source file) as a source attribute".
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.
Seems similar to #178, but with the added bonus of jumping to the target, not just the nearest BUILD file.
Oops you're right!
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.
I'd be interested in implementing both of these, if that's okay with the maintainers.
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...
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.