From 2a71d5cbb0e02e6ff60d39ffb271411239fa6caa Mon Sep 17 00:00:00 2001 From: Spenser Black Date: Sat, 26 Apr 2025 15:13:20 -0400 Subject: [PATCH] Add Pug tree-sitter queries --- runtime/queries/pug/highlights.scm | 111 +++++++++++++++++++++++++++++ runtime/queries/pug/injections.scm | 3 + 2 files changed, 114 insertions(+) create mode 100644 runtime/queries/pug/highlights.scm create mode 100644 runtime/queries/pug/injections.scm diff --git a/runtime/queries/pug/highlights.scm b/runtime/queries/pug/highlights.scm new file mode 100644 index 000000000..084d856d4 --- /dev/null +++ b/runtime/queries/pug/highlights.scm @@ -0,0 +1,111 @@ +(comment) @comment + +( + doctype + (("doctype") @keyword.storage.type) + ((doctype_name) @type.enum.variant) +) + +; Tags +(tag_name) @constant +( + link_tag + ("link" @constant) +) +( + script_tag + ("script" @constant) +) +( + style_tag + ("style" @constant) +) + +; Attributes +(id) @attribute +(class) @attribute +(attribute_name) @attribute + +(quoted_attribute_value) @string + +; Controls +; NOTE: The grammar currently seems to be missing the "if" conditional +( + case + ((keyword) @keyword.control) + ( + when + ((keyword) @keyword.control) + ) +) +( + each + ((keyword) @keyword.control.repeat) + ((iteration_variable) @variable) + ((keyword) @keyword.operator) + ( + 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) + ((keyword) @keyword.directive) + ((block_name) @function.method) +) +( + block_prepend + ((keyword) @keyword.directive) + ((keyword) @keyword.directive) + ((block_name) @function.method) +) + +; Filters +( + filter + (":" @function.macro) + ((filter_name) @function.macro) + ((content) @special) +) + +; Inline JavaScript +( + unbuffered_code + (("-") @operator) +) diff --git a/runtime/queries/pug/injections.scm b/runtime/queries/pug/injections.scm new file mode 100644 index 000000000..328787f57 --- /dev/null +++ b/runtime/queries/pug/injections.scm @@ -0,0 +1,3 @@ +((javascript) @injection.content + (#set! injection.language "javascript") +)