Skip to content

Commit

Permalink
Fix highlighting in string escapes for emacs tree-sitter-mode
Browse files Browse the repository at this point in the history
tree-sitter-mode seems a bit picky about the order in which
expressions are listed in highlights.scm and won't highlight
expressions inside string escapes correctly without this change.
  • Loading branch information
talyz authored and adisbladis committed Jul 7, 2023
1 parent c46ad85 commit d1df27d
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(comment) @comment

[
"if"
"if"
"then"
"else"
"let"
"inherit"
"in"
"rec"
"with"
"with"
"assert"
"or"
] @keyword
Expand All @@ -21,28 +21,11 @@
(#match? @function.builtin "^(__add|__addErrorContext|__all|__any|__appendContext|__attrNames|__attrValues|__bitAnd|__bitOr|__bitXor|__catAttrs|__compareVersions|__concatLists|__concatMap|__concatStringsSep|__deepSeq|__div|__elem|__elemAt|__fetchurl|__filter|__filterSource|__findFile|__foldl'|__fromJSON|__functionArgs|__genList|__genericClosure|__getAttr|__getContext|__getEnv|__hasAttr|__hasContext|__hashFile|__hashString|__head|__intersectAttrs|__isAttrs|__isBool|__isFloat|__isFunction|__isInt|__isList|__isPath|__isString|__langVersion|__length|__lessThan|__listToAttrs|__mapAttrs|__match|__mul|__parseDrvName|__partition|__path|__pathExists|__readDir|__readFile|__replaceStrings|__seq|__sort|__split|__splitVersion|__storePath|__stringLength|__sub|__substring|__tail|__toFile|__toJSON|__toPath|__toXML|__trace|__tryEval|__typeOf|__unsafeDiscardOutputDependency|__unsafeDiscardStringContext|__unsafeGetAttrPos|__valueSize|abort|baseNameOf|derivation|derivationStrict|dirOf|fetchGit|fetchMercurial|fetchTarball|fromTOML|import|isNull|map|placeholder|removeAttrs|scopedImport|throw|toString)$")
(#is-not? local))

[
(string_expression)
(indented_string_expression)
] @string

[
(path_expression)
(hpath_expression)
(spath_expression)
] @string.special.path

(uri_expression) @string.special.uri

[
(integer_expression)
(float_expression)
] @number

(interpolation
"${" @punctuation.special
"}" @punctuation.special) @embedded

(escape_sequence) @escape
(dollar_escape) @escape

Expand Down Expand Up @@ -96,3 +79,21 @@
] @punctuation.bracket

(identifier) @variable

[
(string_expression)
(indented_string_expression)
] @string

[
(path_expression)
(hpath_expression)
(spath_expression)
] @string.special.path

(uri_expression) @string.special.uri

(interpolation
"${" @punctuation.special
(_) @embedded
"}" @punctuation.special)

0 comments on commit d1df27d

Please sign in to comment.