volar-plugins icon indicating copy to clipboard operation
volar-plugins copied to clipboard

Implement volar-service-langium package

Open ejfasting opened this issue 1 year ago • 3 comments

This would make it possible to define a new language with langium and use it through volarjs.

Langium is a DSL design-language, or general language definition language. This might be usefull for those who want to implement their own programming language, with its own syntax, and still make use of Volar and all its capabilities (for example embedding languages together).

ejfasting avatar Oct 10 '24 13:10 ejfasting

Interesting, PR welcome!

remcohaszing avatar Oct 11 '24 09:10 remcohaszing

Guys,

We have a language with LSP server in langium - likec4. We want embed language in markdown, with syntax highlighting, completions and validation from our server. What would you advice?

  1. Like code block, with syntax highlighting, completions and validation:

    
    ## Landscape view
    
    ```likec4
    include element, * -> other
    ```
    
    Some description
    
    
  2. Inside frontmatter?

    ---
    title: Landscape view
    likec4: |
      # Embedded, with syntax highlighting, completions and validation 
      include element, 
        * -> other
    ---
    
    Some description
    
    
  3. Or something like:

    ---
    title: Landscape view
    ---
    <likec4>
      # Embedded, with syntax highlighting, completions and validation 
      include element, 
        * -> other
    </likec4>
    
    Some description
    
    

Assuming, this can be applied only to known markdown files (in some folder). Do we need separate lsp server and provide language-service to volar? Or hook with middlewares?

davydkov avatar Jan 29 '25 21:01 davydkov

Hi @davydkov

How you implement this depends on what you find easiest, but from my own experience i would prefer option1. You can then scan the document for your tag and pass that to your langium lsp.

This issue is about how you integrate langium with volar, and creating the middleware to simplify it. Without that you would need to figure out how to pass things from volar to langium, and handle the optimizations that is built-inn when you use the lsp-sample that langium creates for you (primarily the documenthandler, so langium caches documents instead of passing the whole document on each edit).

I never got around to fully create a poc, but it could be interesting to hear about your experience/findings as you give it a try :)

//e

ejfasting avatar Feb 04 '25 06:02 ejfasting