From 7aa24acae3a288e442e06928171f360bbdf75ba4 Mon Sep 17 00:00:00 2001 From: purarue <7804791+purarue@users.noreply.github.com> Date: Sun, 14 Sep 2025 08:53:21 +0000 Subject: feat(rifleconf): add parser and queries --- runtime/queries/rifleconf/highlights.scm | 31 +++++++++++++++++++++++++++++++ runtime/queries/rifleconf/injections.scm | 16 ++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 runtime/queries/rifleconf/highlights.scm create mode 100644 runtime/queries/rifleconf/injections.scm (limited to 'runtime') diff --git a/runtime/queries/rifleconf/highlights.scm b/runtime/queries/rifleconf/highlights.scm new file mode 100644 index 000000000..2ac837a3e --- /dev/null +++ b/runtime/queries/rifleconf/highlights.scm @@ -0,0 +1,31 @@ +(comment) @comment @spell + +[ + "," + ";" +] @punctuation.delimiter + +[ + "=" + (condition_negation) +] @operator + +; mark the string values for items interpreted as regex as string.regexp +(binary_condition_expression + (binary_condition_identifier) @_keyword + (identifier) @string.regexp + (#any-of? @_keyword "match" "ext" "mime" "name" "path")) + +(binary_condition_identifier) @keyword + +(unary_condition_identifier) @keyword + +(condition_expression + (binary_condition_expression + (binary_condition_identifier) @keyword + (identifier) @number) + (#eq? @keyword "number")) + +(ask) @function.builtin + +(string) @string diff --git a/runtime/queries/rifleconf/injections.scm b/runtime/queries/rifleconf/injections.scm new file mode 100644 index 000000000..e0463982f --- /dev/null +++ b/runtime/queries/rifleconf/injections.scm @@ -0,0 +1,16 @@ +; These are all interpreted as regex when evaluated +; https://github.com/ranger/ranger/blob/38bb8901004b75a407ffee4b9e176bc0a436cb15/ranger/ext/rifle.py#L273-L282 +(binary_condition_expression + (binary_condition_identifier) @_keyword + (identifier) @injection.content + (#any-of? @_keyword "match" "ext" "mime" "name" "path") + (#set! injection.language "regex")) + +; highlight any commands using the bash tree-sitter parser +(command_list + (command) @injection.content + (#set! injection.include-children) + (#set! injection.language "bash")) + +((comment) @injection.content + (#set! injection.language "comment")) -- cgit v1.2.3-70-g09d2