From 0cbd5561d2ad9afa3dbf841409ef22fc0b0ca993 Mon Sep 17 00:00:00 2001 From: lelgenio Date: Sat, 3 Feb 2024 16:01:06 -0300 Subject: [PATCH] Add blade templates support --- book/src/generated/lang-support.md | 1 + languages.toml | 11 +++++++++++ runtime/queries/blade/folds.scm | 8 ++++++++ runtime/queries/blade/highlights.scm | 4 ++++ runtime/queries/blade/injections.scm | 18 ++++++++++++++++++ 5 files changed, 42 insertions(+) create mode 100644 runtime/queries/blade/folds.scm create mode 100644 runtime/queries/blade/highlights.scm create mode 100644 runtime/queries/blade/injections.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 0c1997e44e13d..18ce87a427263 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -8,6 +8,7 @@ | beancount | ✓ | | | | | bibtex | ✓ | | | `texlab` | | bicep | ✓ | | | `bicep-langserver` | +| blade | ✓ | | | | | blueprint | ✓ | | | `blueprint-compiler` | | c | ✓ | ✓ | ✓ | `clangd` | | c-sharp | ✓ | ✓ | | `OmniSharp` | diff --git a/languages.toml b/languages.toml index 14e432827a078..83f8e53a333cf 100644 --- a/languages.toml +++ b/languages.toml @@ -891,6 +891,17 @@ indent = { tab-width = 4, unit = " " } name = "php-only" source = { git = "https://github.com/tree-sitter/tree-sitter-php", rev = "cf1f4a0f1c01c705c1d6cf992b104028d5df0b53", subpath = "php_only" } +[[language]] +name = "blade" +scope = "source.blade.php" +file-types = [{ suffix = ".blade.php" }, "blade"] +injection-regex = "blade" +roots = ["composer.json", "index.php"] + +[[grammar]] +name = "blade" +source = { git = "https://github.com/EmranMR/tree-sitter-blade", rev = "4c66efe1e05c639c555ee70092021b8223d2f440" } + [[language]] name = "twig" scope = "source.twig" diff --git a/runtime/queries/blade/folds.scm b/runtime/queries/blade/folds.scm new file mode 100644 index 0000000000000..c171148212b09 --- /dev/null +++ b/runtime/queries/blade/folds.scm @@ -0,0 +1,8 @@ +((directive_start) @start + (directive_end) @end.after + (#set! role block)) + + +((bracket_start) @start + (bracket_end) @end + (#set! role block)) \ No newline at end of file diff --git a/runtime/queries/blade/highlights.scm b/runtime/queries/blade/highlights.scm new file mode 100644 index 0000000000000..b3d442a05f630 --- /dev/null +++ b/runtime/queries/blade/highlights.scm @@ -0,0 +1,4 @@ +(directive) @tag +(directive_start) @tag +(directive_end) @tag +(comment) @comment diff --git a/runtime/queries/blade/injections.scm b/runtime/queries/blade/injections.scm new file mode 100644 index 0000000000000..b292eb916e7f1 --- /dev/null +++ b/runtime/queries/blade/injections.scm @@ -0,0 +1,18 @@ +((text) @injection.content + (#not-has-ancestor? @injection.content "envoy") + (#set! injection.combined) + (#set! injection.language php)) + +; could be bash or zsh +; or whatever tree-sitter grammar you have. +((text) @injection.content + (#has-ancestor? @injection.content "envoy") + (#set! injection.combined) + (#set! injection.language bash)) + + +((php_only) @injection.content + (#set! injection.language php-only)) +((parameter) @injection.content + (#set! injection.language php-only)) +