From 81660800352ecab6a2e95f4ca30d637df1f3765e Mon Sep 17 00:00:00 2001 From: ObserverOfTime Date: Sun, 21 Jan 2024 12:57:34 +0200 Subject: [PATCH] feat(yuck): add missing injections And builtin variable highlights --- queries/yuck/highlights.scm | 21 +++++++++++---------- queries/yuck/injections.scm | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/queries/yuck/highlights.scm b/queries/yuck/highlights.scm index bd414b8e7..2d5d01c0b 100644 --- a/queries/yuck/highlights.scm +++ b/queries/yuck/highlights.scm @@ -6,16 +6,14 @@ ; Includes (list . - ((symbol) @keyword.import - (#eq? @keyword.import "include"))) + (symbol) @keyword.import + (#eq? @keyword.import "include")) ; Keywords -; I think there's a bug in tree-sitter the anchor doesn't seem to be working, see -; https://github.com/tree-sitter/tree-sitter/pull/2107 (list . - ((symbol) @keyword - (#any-of? @keyword "defwindow" "defwidget" "defvar" "defpoll" "deflisten" "geometry" "children" "struts"))) + (symbol) @keyword + (#any-of? @keyword "defwindow" "defwidget" "defvar" "defpoll" "deflisten" "geometry" "children" "struts")) ; Loop (loop_widget @@ -39,8 +37,8 @@ ; Builtin widgets (list . - ((symbol) @tag.builtin - (#any-of? @tag.builtin "box" "button" "calendar" "centerbox" "checkbox" "circular-progress" "color-button" "color-chooser" "combo-box-text" "eventbox" "expander" "graph" "image" "input" "label" "literal" "overlay" "progress" "revealer" "scale" "scroll" "transform"))) + (symbol) @tag.builtin + (#any-of? @tag.builtin "box" "button" "calendar" "centerbox" "checkbox" "circular-progress" "color-button" "color-chooser" "combo-box-text" "eventbox" "expander" "graph" "image" "input" "label" "literal" "overlay" "progress" "revealer" "scale" "scroll" "transform")) ; Variables (ident) @variable @@ -48,7 +46,10 @@ (array (symbol) @variable) -; Properties & Fields +((ident) @variable.builtin + (#any-of? @variable.builtin "EWW_TEMPS" "EWW_RAM" "EWW_DISK" "EWW_BATTERY" "EWW_CPU" "EWW_NET" "EWW_TIME" "EWW_CONFIG_DIR" "EWW_CMD" "EWW_EXECUTABLE")) + +; Properties (keyword) @property (json_access @@ -72,7 +73,7 @@ (json_object (simplexpr - (ident) @variable.member)) + (ident) @property)) ; Functions (function_call diff --git a/queries/yuck/injections.scm b/queries/yuck/injections.scm index 2f0e58eb6..298a8d070 100644 --- a/queries/yuck/injections.scm +++ b/queries/yuck/injections.scm @@ -1,2 +1,26 @@ ((comment) @injection.content (#set! injection.language "comment")) + +((function_call + name: (ident) @_name + . + (simplexpr) + . + (simplexpr + (string + (string_fragment) @injection.content)+)) + (#any-of? @_name "replace" "search" "matches" "captures") + (#set! injection.language "regex") + (#set! injection.combined)) + +((function_call + name: (ident) @_name + . + (simplexpr) + . + (simplexpr + (string + (string_fragment) @injection.content)+)) + (#eq? @_name "jq") + (#set! injection.language "jq") + (#set! injection.combined))