(lsp) scaffold out basic lsp server #69
Merged
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.
This creates a basic LSP server and cobbles together a VSCode extension based on some of the guides available, in order to get semantic highlighting just about working.
Some notes:
hdx_lsp
offers the main functionality of the LSP. Theres a server core which is more of a library, it usesCrossbeam
to do threaded handling of requests and responses, routing is very simple and usesDashMap<&'static str, RequestHandler>
to map requests to their relative handlers. I looked into Tower LSP but I wanted to get to grips with the protocol a little more, so this simple handler pattern made more sense to me. A lot of heavy lifting is done vialsp_types
which saved a ton of time getting stuff working.tracing
which is a really neat library and I am kind of tempted to shove it everywhere - maybe it would be good for perf tracing in the parser itself?hdx
binary now offers anlsp
command. The VSCode extension then can call out tohdx lsp
to delegate all the work to that. There's sadly still some stuff that needs defining in the extension - mostly fallback styles for semantic tokens. Largely though it all communicates through the LSP, which is great because this means it can eventually scan for local copies of hdx or download the latest version without any updates to the extension.DashMap
of file URIs to Strings. We should be more advanced here and do stuff like:Next up we need a lot of work on Visitor traits, and to implement more token highlighting. Also the test suite needs some improvements. Overall though I am happy with this as a first step!