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 fcb5e61
Show file tree
Hide file tree
Showing 8 changed files with 3,941 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
9 changes: 8 additions & 1 deletion queries-src/injections.scm
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
((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
9 changes: 8 additions & 1 deletion queries/just/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
((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 fcb5e61

Please sign in to comment.