Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here's a first pass on the tree-sitter performance changes I asked about in #39. I brought in the lsp_textdocument crate to help manage in-memory copies of the buffers being edited. Using this crate, text edits can now be communicated and applied incrementally, as opposed to copying over the entire document every time a change is made. I also co-located a tree-sitter tree in the global text store map so that each document now has a corresponding tree. With this in place, the trees can now be maintained incrementally alongside the in-memory buffers. Edits are applied eagerly to each tree (inside
handle_didChange()
), but the tree is only re-parsed lazily as needed (inget_position_from_lsp_completion()
).I also swapped out the protocol-related structs defined in
lsp/src/handle.rs
with their equivalents from thelsp_types
crate, as the crate's structs have some extra information by more closely matching the lsp spec. Some of this extra info was needed to interface with thelsp_textdocument
crate, but using the crate's types should also make things easier to maintain overall.I made some assumptions about how this should be implemented, so if there needs to be any changes/ refactoring I'm happy to work through that :)
Apologies that this PR is a bit on the long side, but the tree-sitter changes had to touch a couple different parts of the code base.
Closes #39