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

feat: Add code lenses with '# of references' (server side) #272

Merged
merged 3 commits into from
Nov 29, 2023

Conversation

artempyanykh
Copy link
Owner

@artempyanykh artempyanykh commented Nov 29, 2023

This just provides a lens with something like '4 references' next to a header.
Clicking on the lens won't actually do anything yet because command handling needs to be implemented by every client.

This (partially) addresses #28

NOTE: after #269 references are resolved incrementally based on document symbols rather than CSTs; which makes 'find references' requests practically free and lenses very cheap. Before #269 a code lens with references would be very expensive.

TODO:

  • references for headers
  • references for link defs

incr-references

This just provides a lens with something like '4 references' next to a header.
Clicking on the lens won't actually do anything yet because command handling needs to be implemented by every client.
@artempyanykh artempyanykh merged commit 6c8e995 into main Nov 29, 2023
3 checks passed
@artempyanykh artempyanykh deleted the codelenses branch November 29, 2023 11:33
@rchl
Copy link

rchl commented Dec 1, 2023

Clicking on the lens won't actually do anything yet because command handling needs to be implemented by every client.

What do you intend to do about that? I believe delegating this to the client is the only option really. At least until LSP spec adds something for that.

@artempyanykh
Copy link
Owner Author

What do you intend to do about that? I believe delegating this to the client is the only option really. At least until LSP spec adds something for that.

@rchl yes, it is client specific. If some clients really want custom bits to invoke 'find reference' when clicking on a lens, I'm open to adding the required functionality. But otherwise, just having the lens there gives me 90% of the value and I don't mind triggering 'find references' manually with a key binding.

@rchl
Copy link

rchl commented Dec 9, 2023

Currently it feels broken because a command is provided and editors make it look like it's possible to execute it but invoking it fails (differently in different editors I guess). I suggest just expose the missing data (the references) and let the clients handle it.

@artempyanykh
Copy link
Owner Author

Yes, it is different in different editors. VSCode actually shows an error banner which is really annoying. This is why I added whatever data VSCode needs to implement the command on the client side in #284 (+ relevant client-side code here). You'd need to pass experimental.codeLensFindReferences capability from the client to turn this on. Later I plan to implement codeLens/resolve to avoid passing the list of reference locations for all lenses every time.

@rchl can you use #284 for Sublime?

@rchl
Copy link

rchl commented Dec 10, 2023

Yes, that works for me, thanks.

@rchl
Copy link

rchl commented Dec 10, 2023

Later I plan to implement codeLens/resolve to avoid passing the list of reference locations for all lenses every time.

If it's cheap to provide them right away then IMO it wouldn't be necessary to provide resolve functionality. Unless maybe the data size would be an issue but it's hard to imagine that it would (unless in some pathological cases).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants