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

Support sellection ranges LSP API #777

Closed
matklad opened this issue Nov 23, 2022 · 3 comments · Fixed by #784
Closed

Support sellection ranges LSP API #777

matklad opened this issue Nov 23, 2022 · 3 comments · Fixed by #784
Labels
enhancement New feature or request

Comments

@matklad
Copy link
Contributor

matklad commented Nov 23, 2022

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_selectionRange

The TL;DR of the feature is that the server informs the editor about the ranges of syntax constructs at the cursor position (eg, the expression, statement, function, etc at cursor), which the editor than uses to provide smart "extend selection" action which is helfpul to select syntactically self-contained fragment.

This is a relatively important feature to support, as it unlocks powerful editing capabilities.
It also should be relatively easy to add support for, as it only needs information about syntax.

@matklad matklad added the enhancement New feature or request label Nov 23, 2022
@SuperAuguste
Copy link
Member

Huh, I've never seen this before - looks awesome! Let me know if you'd like to take a jab at it, otherwise someone'll get to it eventually :)

@matklad
Copy link
Contributor Author

matklad commented Nov 23, 2022

I am not very likely to look into this super-soon, but will probably get to this eventually if no one beats me to it.

Any pointers to the source code (eg, where to add support for new LSP request, where to add tests, how to get a syntax tree) would be appreciated!

@SuperAuguste
Copy link
Member

New requests can be added here - just model your new function based on the others present. Here's an example showing how to get a DocumentStore.Handle (handle.tree will get you an AST). You can plop new tests in here - just model them after existing ones.

matklad added a commit to matklad/zls that referenced this issue Nov 26, 2022
matklad added a commit to matklad/zls that referenced this issue Nov 26, 2022
matklad added a commit to matklad/zls that referenced this issue Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants