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

Add option to exclude the definition from references in LSP searches #5344

Closed
effinsky opened this issue Dec 30, 2022 · 5 comments · Fixed by #6886
Closed

Add option to exclude the definition from references in LSP searches #5344

effinsky opened this issue Dec 30, 2022 · 5 comments · Fixed by #6886
Labels
A-language-server Area: Language server client C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much

Comments

@effinsky
Copy link

The first ref search result is actually definition that I started the search from:
Screenshot 2022-12-30 at 11 07 17

As far as I'm concerned, it should not be listed at all. Relatedly, It would be cool if a jump happened straight to reference if only one exists, with the search window never appearing.

@effinsky effinsky added the C-enhancement Category: Improvements label Dec 30, 2022
@the-mikedavis the-mikedavis added the A-language-server Area: Language server client label Dec 30, 2022
@the-mikedavis
Copy link
Member

It's possible to configure this in the LSP references request: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#referenceContext. Currently we hard-code this to true but it could be configurable.

It would be cool if a jump happened straight to reference if only one exists, with the search window never appearing.

That is how goto-references should behave if the language server only sends one location:

[location] => {
jump_to_location(editor, location, offset_encoding, Action::Replace);
}

@pascalkuthe
Copy link
Member

It's possible to configure this in the LSP references request: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#referenceContext. Currently we hard-code this to true but it could be configurable.

I wanted to send a PR for this but didn't get around to this yet. Was it a concious choice to hardcode true here? It seems like false would be the better default here since you can always use gd instead. I didn't find prior discussion the last time I looked into this

@the-mikedavis
Copy link
Member

The descision/code predates me (#8) but the true default seems sensible to me. IMO the definition is a reference - when I want to see and especially edit all instances of some symbol, I expect to see the definition too. I'm curious what other editors use for a default here.

@effinsky
Copy link
Author

I'm cool with this being the default if most folks find that useful and/or consistent with their expectations. I'd just like to be able to exclude it in a cfg opt and jump straight to a sole reference other than the def as well.

@Omnikar
Copy link
Contributor

Omnikar commented Jan 4, 2023

I'd say a good default behaviour is listing the definition reference at the bottom of the list, which seems to already be how it behaves for Rust.

@pascalkuthe pascalkuthe added E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors labels Apr 26, 2023
@pascalkuthe pascalkuthe changed the title Exclude the definition from references in LSP searches and also jump straight to reference if only one exists Add option to exclude the definition from references in LSP searches Apr 26, 2023
mcdoker18 added a commit to mcdoker18/helix that referenced this issue Apr 26, 2023
@pascalkuthe pascalkuthe removed the E-good-first-issue Call for participation: Issues suitable for new contributors label Apr 26, 2023
mcdoker18 added a commit to mcdoker18/helix that referenced this issue Apr 27, 2023
pascalkuthe pushed a commit that referenced this issue Apr 27, 2023
…6886)

* feat: added the config option to exclude declaration from reference query

Fixes: #5344

* fix: review

* fix: review
Triton171 pushed a commit to Triton171/helix that referenced this issue Jun 18, 2023
…elix-editor#6886)

* feat: added the config option to exclude declaration from reference query

Fixes: helix-editor#5344

* fix: review

* fix: review
wes-adams pushed a commit to wes-adams/helix that referenced this issue Jul 4, 2023
…elix-editor#6886)

* feat: added the config option to exclude declaration from reference query

Fixes: helix-editor#5344

* fix: review

* fix: review
smortime pushed a commit to smortime/helix that referenced this issue Jul 10, 2024
…elix-editor#6886)

* feat: added the config option to exclude declaration from reference query

Fixes: helix-editor#5344

* fix: review

* fix: review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-server Area: Language server client C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants