Skip to content

Commit

Permalink
fixes #41, fixes #42. Adjusted injections.scm
Browse files Browse the repository at this point in the history
  • Loading branch information
EmranMR committed Dec 4, 2023
1 parent 3743999 commit 72a5e16
Show file tree
Hide file tree
Showing 6 changed files with 144,100 additions and 179,596 deletions.
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

- 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](https://github.com/EmranMR/tree-sitter-blade/releases/tag/v0.9.0), if
you have any questions feel free to start a discussion or raise an
issue
- Please read the `v0.9.0`
[Release Note for the Upgrade Guide](https://github.com/EmranMR/tree-sitter-blade/releases/tag/v0.9.0),
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
Expand Down Expand Up @@ -86,6 +87,7 @@ of use I have narrowed everything down to the following rules/queries:
```scm
((text) @injection.content
(#not-has-ancestor? @injection.content "envoy")
(#not-has-parent? @injection.content "comment")
(#set! injection.combined)
(#set! injection.language php))
```
Expand All @@ -98,35 +100,25 @@ of use I have narrowed everything down to the following rules/queries:
- You inject `php_only` into `(php_only)` nodes. This is for all the
php directives including `{{ x }}`, `{!! x !!}} ` and so forth
- Optional: `(#set! injection.combined)` but considering laravel
will render the different `php_only` points like having multiple
`<?php code ?>` The codes should have the same scope. In Nova you
also get extra autocompletion which are built-in.

```scm
((php_only) @injection.content
(#set! injection.combined)
(#set! injection.language php_only))
```

### 3. (parameter) 🚧
### 3. optional: (parameter) 🚧

> This will be availble once the
> [split parser](https://github.com/tree-sitter/tree-sitter-php/pull/180)
> is merged into `tree-sitter-php`.The name might also change.
- optional: It will add a nice syntax highlighting for your
parameters
- It will add a nice syntax highlighting for your parameters
- This is also a php injection point. I initially had this aliased
as `(php_only)`, however I decided to keep it separate.
- This is for all the inline directives such as `@extends(x)`,
`@yield(x)` and so forth
- you inject `php_only` in `(parameter)` to get a nice syntax
highlighting
- Do **_NOT_** add `(#set! injection.combined)`
- Because they are _parameter_.
- This is just for syntax highlighting and getting a nice `php`
IDE autocompletion if supported by your editor.

```scm
((parameter) @injection.content
Expand All @@ -139,7 +131,8 @@ of use I have narrowed everything down to the following rules/queries:
- Mainly to parse stuff inside `@task`
- You will get a nice `shell` syntax highlighting and possibly
completion when writing your envoys
- For your hooks, `@before, @after ... ` you will get `php_only` injections provided by the code above, automatically.
- For your hooks, `@before, @after ... ` you will get `php_only`
injections provided by the code above, automatically.
> You can use whatever you want, zsh etc Here is an an example
> with `bash`
Expand Down
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = grammar({
name: 'blade',
extras: ($) => [$.comment, /\s+/],

rules: {
blade: ($) => repeat($._definition),
Expand All @@ -13,6 +12,7 @@ module.exports = grammar({
$._inline_directive,
$._nested_directive,
$.loop_operator,
$.comment,
$.text
),

Expand Down
2 changes: 1 addition & 1 deletion queries/injections.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
((text) @injection.content
(#not-has-ancestor? @injection.content "envoy")
(#not-has-parent? @injection.content "comment")
(#set! injection.combined)
(#set! injection.language php))

Expand All @@ -12,7 +13,6 @@


((php_only) @injection.content
(#set! injection.combined)
(#set! injection.language php_only))
((parameter) @injection.content
(#set! injection.language php_only))
Expand Down
10 changes: 5 additions & 5 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
"type": "SYMBOL",
"name": "loop_operator"
},
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "SYMBOL",
"name": "text"
Expand Down Expand Up @@ -2371,13 +2375,9 @@
}
},
"extras": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "PATTERN",
"value": "\\s+"
"value": "\\s"
}
],
"conflicts": [],
Expand Down
52 changes: 52 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down Expand Up @@ -149,6 +153,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down Expand Up @@ -259,6 +267,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down Expand Up @@ -393,6 +405,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down Expand Up @@ -492,6 +508,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down Expand Up @@ -633,6 +653,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down Expand Up @@ -732,6 +756,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down Expand Up @@ -858,6 +886,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down Expand Up @@ -976,6 +1008,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down Expand Up @@ -1123,6 +1159,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down Expand Up @@ -1222,6 +1262,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down Expand Up @@ -1321,6 +1365,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down Expand Up @@ -1425,6 +1473,10 @@
"type": "bracket_start",
"named": true
},
{
"type": "comment",
"named": true
},
{
"type": "conditional",
"named": true
Expand Down
Loading

0 comments on commit 72a5e16

Please sign in to comment.