starpls icon indicating copy to clipboard operation
starpls copied to clipboard

Jump through aliases with go to definition

Open keith opened this issue 9 months ago • 1 comments

It seems that by default the definition LSP call will (reasonably) jump to the common pattern where folks re-export symbols. I think in the common case I would prefer it jump through that alias straight to the underlying definition.

For example on this rule:

shared_library( < - cursor somewhere on this line
    name = "foo",
    srcs = glob(["*.cpp"]),
    ...
)

And you jump to the definition, you can end up in a file like this:

load("//bazel/internal:shared_library.bzl", _shared_library = "shared_library")
shared_library = _shared_library

Then you need to do another jump to definition on the right hand side of the assignment to get through to the underlying definition.

keith avatar Apr 09 '25 16:04 keith

maybe this can be what go to declaration does?

PeterCardenas avatar May 20 '25 18:05 PeterCardenas

"Go to Declaration" now does this by default! You can also enable the --experimental_goto_definition_skip_re_exports flag to enable this for "Go to Definition" as well if you so like

withered-magic avatar Jun 29 '25 00:06 withered-magic