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) scaffold out basic lsp server #69

Merged
merged 4 commits into from
Dec 16, 2024

Conversation

keithamus
Copy link
Owner

@keithamus keithamus commented Dec 16, 2024

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 uses Crossbeam to do threaded handling of requests and responses, routing is very simple and uses DashMap<&'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 via lsp_types which saved a ton of time getting stuff working.
  • This also uses 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?
  • The hdx binary now offers an lsp command. The VSCode extension then can call out to hdx 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.
  • Right now the LSP logic is pretty ropey; highlighting requires reparsing each time and we're storing a DashMap of file URIs to Strings. We should be more advanced here and do stuff like:
  • Threaded parsing/highlighting in something like a deque.
  • Storing files in a virtual file system.
  • Actually updated files in edits, so we can re-parse on each edit.

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!

@keithamus keithamus marked this pull request as ready for review December 16, 2024 00:27
@keithamus keithamus merged commit 3fa5bcd into main Dec 16, 2024
1 check failed
@keithamus keithamus deleted the lsp-scaffold-out-basic-lsp-server branch December 16, 2024 00:33
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

Successfully merging this pull request may close these issues.

1 participant