diff --git a/README.md b/README.md index adbc308..52256b1 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,18 @@ > The grammar is up to date as of **_Laravel 10.x_** +## ⚠️ v0.9.0 Update ✨ + +- There has been some structural refactor to make the grammar future + proof, semantic and flexible as it grows with Laravel +- Please read the `v0.9.0` Release Note for the upgrade guide, if + you have any questions feel free to start a discussion or raise an + issue +- As soon as you change your `injections.scm` you are good to go ✅ + to enjoy all the new features ✨ +- I have also updated the instructions underneath 👇 for new and + upcoming users + ## Introduction (feel free to skip) This project aims to write the tree-sitter grammar for @@ -67,16 +79,15 @@ When you parse your code there are three main important injection points. There is an example in the `queries/injection.scm`. For ease of use I have narrowed everything down to the following rules/queries: -### 1. (php) +### 1. html/php - This will inject `html/php` into your document -- You need to inject `php` in the `(php)` nodes -- make sure it is `(#set! injection.combined)` ```scm -((php) @injection.content - (#set! injection.combined) - (#set! injection.language php)) +((text) @injection.content + (#not-has-ancestor? @injection.content "envoy") + (#set! injection.combined) + (#set! injection.language php)) ``` ### 2. (php_only) 🚧 @@ -102,7 +113,7 @@ of use I have narrowed everything down to the following rules/queries: > This will be availble once the > [split parser](https://github.com/tree-sitter/tree-sitter-php/pull/180) -> is merged into `tre-sitter-php`.The name might also change. +> is merged into `tree-sitter-php`.The name might also change. - optional: It will add a nice syntax highlighting for your parameters @@ -123,21 +134,24 @@ directive parameters (#set! injection.language php_only)) ``` -### 4. (shell) +### 4. Envoy/Bash - This is used specifically for Laravel Envoy - Mainly to parse stuff inside `@task` - You will get a nice `shell` syntax highlighting and possibly completion when writing your envoys - > You can use whatever you want, zsh etc, I am just using `sh` as - > an example + > You can use whatever you want, zsh etc Here is an an example + > with `bash` ```scm -((shell) @injection.content +((text) @injection.content + (#has-ancestor? @injection.content "envoy") (#set! injection.combined) - (#set! injection.language sh)) + (#set! injection.language bash)) ``` +php injection + ### 5. (javascript) - TBA @@ -230,7 +244,7 @@ implement the folding (#set! role block)) ``` -php injection +php injection ## Quick Note about `queries/` folder diff --git a/package.json b/package.json index 1cbb7aa..5ee649f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tree-sitter-blade", - "version": "0.8.0", + "version": "0.9.0", "description": "tree-sitter-blade grammar for Laravel Blade files", "main": "bindings/node", "keywords": [ diff --git a/queries/folds.scm b/queries/folds.scm index 75b7b42..c171148 100644 --- a/queries/folds.scm +++ b/queries/folds.scm @@ -1,12 +1,8 @@ -( - (directive_start) @start +((directive_start) @start (directive_end) @end.after - (#set! role block) -) + (#set! role block)) -( - (bracket_start) @start +((bracket_start) @start (bracket_end) @end - (#set! role block) -) \ No newline at end of file + (#set! role block)) \ No newline at end of file diff --git a/queries/injections.scm b/queries/injections.scm index c62d896..aae02ef 100644 --- a/queries/injections.scm +++ b/queries/injections.scm @@ -3,10 +3,12 @@ (#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 shell)) + (#set! injection.language bash)) ((php_only) @injection.content