Stream: t-compiler/rust-analyzer

Topic: Dumping buffer representation from Rust-analyzer


Michael Lingelbach (Feb 24 2021 at 07:37, on Zulip):

Hi! I'm a contributor to neovim's language server client implementation. I'm implementing incremental sync for neovim, and was hoping to use rust-analyzer to test whether we are sending the correct ranges. I can't seem to find in which crate the actual handler for textDocument/didChange is found (tried searching the rust-analyzer org via GH search, rust-analyzer itself, and several crates). I'd like to dump the internal representation of the buffer to a file on each change notification so that I can compare our client to what rust-analyzer believes we have sent.

Laurențiu (Feb 24 2021 at 07:50, on Zulip):

You could add some logging to the console or to a file if that works for you

Laurențiu (Feb 24 2021 at 07:51, on Zulip):

The changes are applied in this function https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/rust-analyzer/src/lsp_utils.rs#L92-L139

Laurențiu (Feb 24 2021 at 07:54, on Zulip):

The entry point for textDocument/didChange is https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/rust-analyzer/src/main_loop.rs#L584-L605, but there's not much happening besides apply_document_changes

Michael Lingelbach (Feb 24 2021 at 08:06, on Zulip):

This is exactly what I was looking for! Thank you. What I did with julia language server was dump to a file, so I think that's what I'll do here. Unfortunately they don't yet support incremental sync.

Laurențiu (Feb 24 2021 at 08:14, on Zulip):

Yup. Feel free to ask if you need more help (even if t it's e.g. writing to a file or compiling the code)

Last update: Jul 28 2021 at 03:30UTC