Skip to content

Using tree-sitter to assist LSP completion #3346

Answered by WillLillis
Ce11an asked this question in Q&A
Discussion options

You must be logged in to vote

I added some rudimentary completion capabilities to asm-lsp using tree-sitter's rust bindings. The basic building blocks for this were:

  • Maintain an in-memory copy of the source file being edited. This copy can be updated in step with edits made to the source file in two ways:
    • Incremental -- The LSP client sends edits over that you then apply to your copy. If you're writing the LSP in Rust the lsp-textdocument crate makes this fairly straightforward
    • Full -- The client sends a full copy of the document each time it's edited. This is much simpler but also comes at a performance cost, especially as the documents grow larger.
  • Alongside the in-memory copy of the source file, maintain a tree…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@Ce11an
Comment options

@WillLillis
Comment options

@Ce11an
Comment options

Answer selected by Ce11an
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants