Skip to content

Commit

Permalink
v0.9.0 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
EmranMR committed Dec 3, 2023
1 parent e87e0b9 commit e31bfc2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) 🚧
Expand All @@ -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
Expand All @@ -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))
```

<img src="https://github.com/EmranMR/Laravel-Nova-Extension/blob/main/Images/Envoy%20Injection.png?raw=true" width="60%" style="border-radius: 2%" alt="php injection" title="php injection" />

### 5. (javascript)

- TBA
Expand Down Expand Up @@ -230,7 +244,7 @@ implement the folding
(#set! role block))
```

<img src="https://github.com/EmranMR/Laravel-Nova-Extension/blob/main/Images/php%20injection.gif?raw=true" width="60%" style="border-radius: 2%" alt="php injection" title="php injection" />
<img src="https://raw.githubusercontent.com/EmranMR/Laravel-Nova-Extension/main/Images/folding.gif" width="60%" style="border-radius: 2%" alt="php injection" title="php injection" />

## Quick Note about `queries/` folder

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
12 changes: 4 additions & 8 deletions queries/folds.scm
Original file line number Diff line number Diff line change
@@ -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)
)
(#set! role block))
4 changes: 3 additions & 1 deletion queries/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e31bfc2

Please sign in to comment.