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

feature request: textDocument/selectionRange #125

Open
nishanthkarthik opened this issue Sep 12, 2023 · 1 comment
Open

feature request: textDocument/selectionRange #125

nishanthkarthik opened this issue Sep 12, 2023 · 1 comment

Comments

@nishanthkarthik
Copy link

I would be more than happy to try implementing this myself if you give me a few pointers on how to get started :)

@6cdh
Copy link
Contributor

6cdh commented Sep 12, 2023

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

Basic changes:

  1. you need to update the server capability in methods.rkt.
  2. In methods.rkt, forward textDocument/selectionRange message to another function xx in text-document.rkt.
  3. In xx, check the hash table fields that is converted from the json message, abstract real logic into doc.rkt, and process errors, then return.

Some notes:

  1. The json text are processed by json library
  2. The structs are in struct.rkt that correspond the typescript interface in the specification.
  3. This project is not well maintained. The existing code is not good. Feel free to make the changes as long as you think it's better.
  4. The bad thing is that we don't have reusable infrastructure to maintain a shared AST. So You have to use read/syntax to process text string from scratch.

Personal opinion:

  1. consider use rebellion library. I planned to use it, but don't have time recently.

Implementation discuss:

I don't know how this feature interact with users at editor side. But the specification says typically selection ranges correspond to the nodes of the syntax tree.
You can run read/syntax on the text string, maintain the result between textDocument/didChange requests, and query the node that contains the given position.

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

No branches or pull requests

2 participants