language-server icon indicating copy to clipboard operation
language-server copied to clipboard

Migrate to Volar

Open AngusMorton opened this issue 6 months ago • 6 comments

This is a clean version of https://github.com/marko-js/language-server/pull/294.

This is a proof of concept that shows what it might look like if the Marko Language Tools migrated to Volar as a base.

This proof-of-concept is roughly complete for our purposes, we've been using it for the past few months.

Motivation and Context

Migrating to Volar resolves the issues we've had with the VSCode plugin on Windows (https://github.com/marko-js/language-server/issues/240), and it improves the responsiveness of the plugin on Windows.

Why Volar?

  • Volar provides the glue code that the Marko Langauge Tools currently implement themselves, which means we could potentially shift the maintenance/implementation burden off the Marko team.
  • Vue and Astro use Volar for their Language Tools, so it's fairly well used.
  • The patterns in Volar are very similar to what is already here, so the migration is relatively straightforward.
    • MarkoFile -> MarkoVirtualCode
    • Plugin -> LanguageServicePlugin

TODO

This is fairly untested, I mostly hacked it up so it works with our project.

  • Test with non-TS projects / more project structures.
    • It doesn't appear to work with Node type stripping - Discord?
  • Improve diagnostic mapping?
    • Currently, Volar appears to only map diagnostics if they're wholly contained by a source span, which means we need to do some manual adjustments of diagnostic ranges, which can be less than ideal.

Questions

  • How do Processors fit with Volar? Is there an idiomatic way to do that in Volar?
  • Could we use Volar for marko-type-check? @volar/kit?

AngusMorton avatar Jul 30 '25 02:07 AngusMorton