fix justfile highlighter

This fixes serveral shortcomings of the current implementation:

- valid recipt definitions eg
foo bar="quz":
where previously interrupted by justfile/double_string
and therefore they where not highlighted correctly

- global variable assignments where not captured at all
This commit is contained in:
David Arnold 2020-09-14 16:04:09 -05:00
parent ec3d7c3104
commit 3770baaab0

View File

@ -38,18 +38,23 @@ define-command -hidden just-indent-on-new-line %{
# ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter shared/justfile regions
add-highlighter shared/justfile/content default-region group
add-highlighter shared/justfile/content/recipe regex '^@?([\w-]+)([^\n]*):(?!=)([^\n]*)' 1:function 2:meta 3:keyword
add-highlighter shared/justfile/content/assignments regex ^([\w-]+\h*:=\h*[^\n]*) 1:meta
add-highlighter shared/justfile/content/operator regex '((^@|:=|=|\+|\(|\)))' 1:operator
add-highlighter shared/justfile/content/strings regions
add-highlighter shared/justfile/content/strings/double region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/justfile/content/strings/single region "'" (?<!\\)(\\\\)*' fill string
add-highlighter shared/justfile/comment region '#' '$' fill comment
add-highlighter shared/justfile/double_string region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/justfile/single_string region "'" (?<!\\)(\\\\)*' fill string
add-highlighter shared/justfile/inline region '`' '`' ref sh
add-highlighter shared/justfile/shell region '^\h+' '^[^\h]' group
add-highlighter shared/justfile/shell/ ref sh
add-highlighter shared/justfile/shell/ regex '(\{{2})([\w-]+)(\}{2})' 1:operator 2:variable 3:operator
add-highlighter shared/justfile/shell/ regex '^\h+(@)' 1:operator
add-highlighter shared/justfile/content/ regex '^(@)?([\w-]+)(?:\s(.+))?\s?(:)(.+)?$' 1:operator 2:function 3:value 4:operator 5:type
add-highlighter shared/justfile/content/ regex '([=+])' 1:operator
add-highlighter shared/justfile/content/ regex '^([\w-]+)\s=' 1:value
}