Unnamed repository; edit this file 'description' to name the repository.
Add support for Pug language (#13435)
Spenser Black 10 months ago
parent ece12dd · commit 4784650
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml11
-rw-r--r--runtime/queries/pug/highlights.scm97
-rw-r--r--runtime/queries/pug/injections.scm3
4 files changed, 112 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index d66f7bef..e69d1d84 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -180,6 +180,7 @@
| prolog | ✓ | | ✓ | `swipl` |
| protobuf | ✓ | ✓ | ✓ | `buf`, `pb`, `protols` |
| prql | ✓ | | | |
+| pug | ✓ | | | |
| purescript | ✓ | ✓ | | `purescript-language-server` |
| python | ✓ | ✓ | ✓ | `ruff`, `jedi-language-server`, `pylsp` |
| qml | ✓ | | ✓ | `qmlls` |
diff --git a/languages.toml b/languages.toml
index c44765ad..b28a0c15 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4313,3 +4313,14 @@ comment-tokens = "#"
[[grammar]]
name = "debian"
source = { git = "https://gitlab.com/MggMuggins/tree-sitter-debian", rev = "9b3f4b78c45aab8a2f25a5f9e7bbc00995bc3dde" }
+
+[[language]]
+name = "pug"
+scope = "source.pug"
+file-types = ["pug"]
+comment-tokens = ["//", "//-"]
+indent = { tab-width = 2, unit = " " }
+
+[[grammar]]
+name = "pug"
+source = { git = "https://github.com/zealot128/tree-sitter-pug", rev = "13e9195370172c86a8b88184cc358b23b677cc46" }
diff --git a/runtime/queries/pug/highlights.scm b/runtime/queries/pug/highlights.scm
new file mode 100644
index 00000000..3e5c66fe
--- /dev/null
+++ b/runtime/queries/pug/highlights.scm
@@ -0,0 +1,97 @@
+(comment) @comment
+
+(
+ doctype
+ (("doctype") @keyword.storage.type)
+ ((doctype_name) @type.enum.variant)
+)
+
+(tag_name) @constant
+
+; Attributes
+(id) @attribute
+(class) @attribute
+(attribute_name) @attribute
+
+(quoted_attribute_value) @string
+
+; Controls
+(
+ conditional
+ ((keyword) @keyword.control.conditional)
+)
+(
+ case
+ ((keyword) @keyword.control)
+ (
+ when
+ ((keyword) @keyword.control)
+ )
+)
+(
+ each
+ ((keyword) @keyword.control.repeat)
+)
+(
+ else
+ ((keyword) @keyword.control.conditional)
+)
+(
+ while
+ ((keyword) @keyword.control.repeat)
+)
+
+; Mixins
+(
+ mixin_definition
+ ((keyword) @keyword.function)
+ ((mixin_name) @function.method)
+)
+(
+ mixin_use
+ (("+") @operator)
+ ((mixin_name) @function.method)
+)
+
+; Includes
+(
+ include
+ ((keyword) @keyword.directive)
+ ((filename) @string.special.path)
+)
+
+; Inheritance
+(
+ extends
+ ((keyword) @keyword.directive)
+ ((filename) @string.special.path)
+)
+(
+ block_definition
+ ((keyword) @keyword.directive)
+ ((block_name) @function.method)
+)
+(
+ block_append
+ ((keyword) @keyword.directive)
+ ((block_name) @function.method)
+)
+(
+ block_prepend
+ ((keyword) @keyword.directive)
+ ((block_name) @function.method)
+)
+
+; Filters
+(
+ filter
+ (":" @function.macro)
+ ((filter_name) @function.macro)
+ ((content) @special)
+)
+
+; Inline JavaScript
+(
+ unbuffered_code
+ (("-") @special)
+)
diff --git a/runtime/queries/pug/injections.scm b/runtime/queries/pug/injections.scm
new file mode 100644
index 00000000..328787f5
--- /dev/null
+++ b/runtime/queries/pug/injections.scm
@@ -0,0 +1,3 @@
+((javascript) @injection.content
+ (#set! injection.language "javascript")
+)