Skip to content

Commit

Permalink
Merge pull request #8 from TheBeyondGroup/jeff/update-grammar
Browse files Browse the repository at this point in the history
Update tree-sitter grammar version
  • Loading branch information
jeffreyguenther authored Jan 7, 2025
2 parents 5c82023 + 4c0007c commit 7fb369a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 22 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2024 Jeffrey Guenther
Copyright © 2024 Beyond Group Consulting, Jeffrey Guenther

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ This extension adds syntax highlighting for Liquid to Zed.
More work is needed to bring this extension in line with vscode plugin, so
contributions are welcome!

> [!CAUTION]
> The injections.scm used by this plugin considers the template
> content to only be HTML.
>
> *.js.liquid will not have correctly highlighted JS. No info is derived
> from the file extension to set the base file type.
>
> How to deal with this will come in the future.
## Credits

This extension uses [grammar](https://github.com/hankthetank27/tree-sitter-liquid) and queries from [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter/tree/master/queries/liquid)
4 changes: 2 additions & 2 deletions extension.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
id = "liquid"
name = "Liquid"
version = "0.0.1"
version = "0.0.2"
schema_version = 1
authors = ["Jeffrey Guenther <[email protected]>"]
description = "Shopify Liquid support"
repository = "https://github.com/TheBeyondGroup/zed-shopify-liquid"

[grammars.liquid]
repository = "https://github.com/hankthetank27/tree-sitter-liquid"
commit = "293369818da219d97327908aab33707b04b63fd9"
commit = "23ac814111e2b4b4b083e2c92219af2d5b74d13d"
42 changes: 28 additions & 14 deletions languages/liquid/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
((comment) @comment @spell)
((comment) @comment @spell
(#set! priority 110))

(raw_statement
(raw_content) @spell)
(raw_content) @spell
(#set! priority 110))

((identifier) @variable)
((identifier) @variable
(#set! priority 110))

((string) @string)
((string) @string
(#set! priority 110))

((boolean) @boolean)
((boolean) @boolean
(#set! priority 110))

((number) @number)
((number) @number
(#set! priority 110))

(filter
name: (identifier) @function.special)
name: (identifier) @function.call
(#set! priority 110))

([
"as"
"assign"
"capture"
(custom_unpaired_statement)
"decrement"
"echo"
"endcapture"
Expand All @@ -35,7 +43,8 @@
"schema"
"style"
"with"
] @keyword)
] @keyword
(#set! priority 110))

([
"case"
Expand All @@ -47,27 +56,30 @@
"if"
"unless"
"when"
] @keyword.conditional)
] @keyword.conditional
(#set! priority 110))

([
"break"
(break_statement)
(continue_statement)
"by"
"continue"
"cycle"
"endfor"
"endpaginate"
"endtablerow"
"for"
"paginate"
"tablerow"
] @keyword.repeat)
] @keyword.repeat
(#set! priority 110))

([
"and"
"contains"
"in"
"or"
] @keyword.operator)
] @keyword.operator
(#set! priority 110))

([
"{{"
Expand All @@ -78,10 +90,12 @@
"%}"
"{%-"
"-%}"
] @tag.delimiter)
] @tag.delimiter
(#set! priority 110))

[
"include"
"include_relative"
"render"
"section"
"sections"
Expand Down
16 changes: 11 additions & 5 deletions languages/liquid/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
(#set! "language" "html")
(#set! "combined"))

((json_content) @content
(javascript_statement
(js_content) @content
(#set! "language" "javascript")
(#set! "combined"))

(schema_statement
(json_content) @content
(#set! "language" "json")
(#set! "combined"))

((style_content) @content
(style_statement
(style_content) @content
(#set! "language" "css")
(#set! "combined"))

((js_content) @content
(#set! "language" "javascript")
(#set! "combined"))
((comment) @content
(#set! "language" "comment"))

0 comments on commit 7fb369a

Please sign in to comment.