Skip to content

Instantly share code, notes, and snippets.

@WMcKibbin
Created June 24, 2024 16:18
Show Gist options
  • Save WMcKibbin/7968f64d99c1d6c95ed9aaa6abd75b62 to your computer and use it in GitHub Desktop.
Save WMcKibbin/7968f64d99c1d6c95ed9aaa6abd75b62 to your computer and use it in GitHub Desktop.
Not working yet: Syntax highlighting for alpin in templ files
{
"scopeName": "html.alpinejs.attribute",
"injectionSelector": ["L:text.html.derivative", "L:text.html.php", "L:text.html.twig", "L:source.templ"],
"patterns": [
{
"include": "#alpine-directives"
},
{
"include": "#htmx-directives"
}
],
"repository": {
"alpine-directives": {
"name": "meta.attribute.alpine",
"begin": "(?:\\b(x-)|(:|@|#))([a-zA-Z0-9\\-_]+)(?:\\:([a-zA-Z\\-_]+))?(?:\\.([a-zA-Z0-9\\-_]+))*\\s*(=)",
"end": "(?<='|\")|(?=[\\s<>`])",
"captures": {
"1": {
"name": "entity.other.attribute-name.html"
},
"2": {
"name": "punctuation.separator.key-value.html"
},
"3": {
"name": "entity.other.attribute-name.html"
},
"4": {
"name": "entity.other.attribute-name.html"
},
"5": {
"name": "entity.other.attribute-name.html"
},
"6": {
"name": "punctuation.separator.key-value.html"
}
},
"patterns": [
{
"contentName": "meta.embedded.inline.alpinejs",
"begin": "`",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.html"
}
},
"end": "`",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.html"
}
},
"patterns": [
{
"include": "source.js#expression"
}
]
},
{
"contentName": "meta.embedded.inline.alpinejs",
"begin": "\"",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.html"
}
},
"end": "\"",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.html"
}
},
"patterns": [
{
"include": "source.js#expression"
}
]
},
{
"contentName": "meta.embedded.inline.alpinejs",
"begin": "'",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.html"
}
},
"end": "'",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.html"
}
},
"patterns": [
{
"include": "source.js#expression"
}
]
}
]
},
"htmx-directives": {
"name": "meta.attribute.htmx",
"begin": "(?:\\b(hx-)|(:|@|#))([a-zA-Z0-9\\-_]+)(?:\\:([a-zA-Z\\-_]+))?(?:\\.([a-zA-Z0-9\\-_]+))*\\s*(=)",
"end": "(?<='|\")|(?=[\\s<>`])",
"captures": {
"1": {
"name": "entity.other.attribute-name.html"
},
"2": {
"name": "punctuation.separator.key-value.html"
},
"3": {
"name": "entity.other.attribute-name.html"
},
"4": {
"name": "entity.other.attribute-name.html"
},
"5": {
"name": "entity.other.attribute-name.html"
},
"6": {
"name": "punctuation.separator.key-value.html"
}
},
"patterns": [
{
"contentName": "meta.embedded.inline.htmxjs",
"begin": "`",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.html"
}
},
"end": "`",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.html"
}
},
"patterns": [
{
"include": "source.js#expression"
}
]
},
{
"contentName": "meta.embedded.inline.htmxjs",
"begin": "\"",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.html"
}
},
"end": "\"",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.html"
}
},
"patterns": [
{
"include": "source.js#expression"
}
]
},
{
"contentName": "meta.embedded.inline.htmxjs",
"begin": "'",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.html"
}
},
"end": "'",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.html"
}
},
"patterns": [
{
"include": "source.js#expression"
}
]
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment