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

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

Open
jiawen opened this issue Mar 1, 2024 · 7 comments
Open

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

jiawen opened this issue Mar 1, 2024 · 7 comments
Labels
type: feature request New feature or request

Comments

@jiawen
Copy link

jiawen commented Mar 1, 2024

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 or hdrs.
  • 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".
@catskul
Copy link

catskul commented Mar 4, 2024

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
Copy link
Collaborator

cameron-martin commented Mar 4, 2024

Seems similar to #178, but with the added bonus of jumping to the target, not just the nearest BUILD file.

@jiawen
Copy link
Author

jiawen commented Mar 6, 2024

Oops you're right!

@catskul
Copy link

catskul commented Mar 6, 2024

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.

@cameron-martin cameron-martin added the type: feature request New feature or request label Apr 2, 2024
@kchodorow
Copy link
Contributor

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

@vogelsgesang
Copy link
Collaborator

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
Copy link
Contributor

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.

vogelsgesang pushed a commit that referenced this issue Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants