ttax00 / code-yew-server

An extension that provides some language features for Yew's html macro syntax in Rust
GNU General Public License v3.0
55 stars 4 forks source link

Feature request: support for leptos #21

Open chris-kruining opened 1 year ago

chris-kruining commented 1 year ago

I have tested this plugin by changing only the name of the macro view to html. and it seemed to work fine. is there any chance you are willing to add highligthing for leptos?

looking at the syntax highlighting code I think this should work:

{
    "scopeName": "source.rust.yew",
    "injectionSelector": "L:source.rust",
    "patterns": [
        {
            "include": "#view-macro"
        },
        {
            "include": "#rust-brackets"
        }
    ],
    "repository": {
        "view-macro": {
            "name": "source.rust.leptos.view",
            "begin": "view! {",
            "end": "}",
            "beginCaptures": {
                "0": {
                    "name": "punctuation.macro.open"
                }
            },
            "endCaptures": {
                "0": {
                    "name": "punctuation.macro.close"
                }
            },
            "patterns": [
                {
                    "include": "source.js.jsx"
                }
            ]
        },
        "rust-brackets": {
            "name": "source.rust.leptos",
            "begin": "{",
            "end": "}",
            "patterns": [
                {
                    "include": "source.rust"
                }
            ]
        }
    }
}
ttax00 commented 1 year ago

Hello! Sorry for the late reply.

I haven't play around with leptos yet, but from the looks of your example, i assume the view! macro takes the same syntax as jsx? Feel free to open a PR, since language configurations shouldn't cause much incompatibility issues.

And as always, thanks for filing the issue :smile: