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:
References for the support:
Description
When the
definitionrequest 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 adefinitionrequest whose result includes the cursor, they realize that we would just jumpt back to ourselves, so they issue areferencesrequest 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:
References for the support: