Skip to content

Allow go-to-definition to show references when invoked on a declaration #2725

Description

@tothambrus11

Description

When the definition request is sent at a site of a declaration (e.g. when somebody ctrl+clicks a function declaration's name), we currently return an empty list (or maybe nil?). At least VSCode and Zed have a feature when after a definition request whose result includes the cursor, they realize that we would just jumpt back to ourselves, so they issue a references request and show all the usages of our symbol, which has quite a nice UX.

To enable this, we would need to pattern match the node under cursor, and if it's not a name but a declaration, just return the span of that declaration. I tested this in Hylo's LSP, and this strategy is confirmed to work in VSCode:

Image Image

References for the support:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions