Skip to content

Commit

Permalink
Add back injections for regex literals
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Mar 3, 2024
1 parent b97bf85 commit 089be84
Show file tree
Hide file tree
Showing 9 changed files with 3,964 additions and 3,784 deletions.
5 changes: 4 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,14 @@ module.exports = grammar({
choice(
seq($.expression, "==", $.expression),
seq($.expression, "!=", $.expression),
seq($.expression, "=~", $.expression),
seq($.expression, "=~", choice($.regex_literal, $.expression)),
// verify whether this is valid
$.expression,
),

// Capture this special for injections
regex_literal: ($) => prec(1, $.string),

// value : NAME '(' sequence? ')'
// | BACKTICK
// | INDENTED_BACKTICK
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
],
"locals": [
"queries-src/locals.scm"
],
"injections": [
"queries-src/injections.scm"
]
}
]
Expand Down
7 changes: 6 additions & 1 deletion queries-src/injections.scm
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
((comment) @injection.content
(#set! injection.language "comment"))

(comment) @comment

(recipe_body
(shebang (language) @injection.language)
(#set! injection.include-children)) @injection.content

(comment) @comment
; Highlight the RHS of `=~` as regex
((regex_literal (_) @injection.content)
(#set! injection.language "regex"))

; Defaults if language is not set elsewhere

; (recipe_line
Expand Down
7 changes: 6 additions & 1 deletion queries/just/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
((comment) @injection.content
(#set! injection.language "comment"))

(comment) @comment

(recipe_body
(shebang (language) @injection.language)
(#set! injection.include-children)) @injection.content

(comment) @comment
; Highlight the RHS of `=~` as regex
((regex_literal (_) @injection.content)
(#set! injection.language "regex"))

; Defaults if language is not set elsewhere

; (recipe_line
Expand Down
21 changes: 19 additions & 2 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 089be84

Please sign in to comment.