From a8fd33ac012a79069ef1409503a2edcf3a585153 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 6 Jan 2022 09:00:00 -0600 Subject: add tree-sitter-regex (#1362) * add tree-sitter-regex * adapt regex highlights from upstream * inject regex into elixir sigil_r/2 and sigil_R/2 * generate lang-support docs * capture interesting nodes in character-ranges * make $.character_class captures more consistent * fix fallthrough behavior for character classes * capture pattern characters as 'string' * use latest tree-sitter-regex * set elixir regex injections as combined * add link to upstream queries * inject regex in rust into 'Regex::new' raw string literals--- runtime/queries/elixir/injections.scm | 7 +++++ runtime/queries/regex/highlights.scm | 53 +++++++++++++++++++++++++++++++++++ runtime/queries/rust/injections.scm | 14 +++++++++ 3 files changed, 74 insertions(+) create mode 100644 runtime/queries/regex/highlights.scm (limited to 'runtime') diff --git a/runtime/queries/elixir/injections.scm b/runtime/queries/elixir/injections.scm index 321c90ad..8370a0d8 100644 --- a/runtime/queries/elixir/injections.scm +++ b/runtime/queries/elixir/injections.scm @@ -1,2 +1,9 @@ ((comment) @injection.content (#set! injection.language "comment")) + +((sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content) + (#match? @_sigil_name "^(r|R)$") + (#set! injection.language "regex") + (#set! injection.combined)) diff --git a/runtime/queries/regex/highlights.scm b/runtime/queries/regex/highlights.scm new file mode 100644 index 00000000..9376caa9 --- /dev/null +++ b/runtime/queries/regex/highlights.scm @@ -0,0 +1,53 @@ +; upstream: https://github.com/tree-sitter/tree-sitter-regex/blob/e1cfca3c79896ff79842f057ea13e529b66af636/queries/highlights.scm + +[ + "(" + ")" + "(?" + "(?:" + "(?<" + ">" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "*" + "+" + "|" + "=" + "<=" + "!" + "