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

LSP Toolkit datastructures #26

Open
keynmol opened this issue Aug 26, 2022 · 1 comment
Open

LSP Toolkit datastructures #26

keynmol opened this issue Aug 26, 2022 · 1 comment

Comments

@keynmol
Copy link
Contributor

keynmol commented Aug 26, 2022

There exists perhaps a million reimplementation of the same basic data structures for LSP servers, used both for implementation and testing.

  1. Going from offset to a (line, character)
  2. Going from (line, character) to offset in the document
  3. Getting contents of a line
  4. Finding the (line, character) positions of a given offset range
  5. Cutout text based on a position range
  6. Apply a text edit to given range
  7. etc.

It would be good to provide efficient implementations (may be even special cased for platforms!) of these operations, implemented in terms of the LSP structures like Position and Range, so that LSP authors don't reimplement the wheel unnecessarily.

You can see one such implementation here: https://github.com/artempyanykh/marksman/blob/main/Marksman/Text.fs

@kubukoz
Copy link
Contributor

kubukoz commented Nov 4, 2022

offset -> (line, character) and vice versa are implemented in cats-parse's LocationMap if you want some inspiration :)

Would you say having a "text document manager" would be in scope? vscode-languageserver-node has one, it makes it easier to read a file's contents without having to listen to change events manually.

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