Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Git Formats] Update to sublime-syntax version 2 #3056

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions Git Formats/Git Attributes.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
# Examples: https://github.com/alexkaratarakis/gitattributes

name: Git Attributes
scope: text.git.attributes
version: 2

file_extensions:
- attributes # .git/info/attributes
- gitattributes # *.gitattributes
- .gitattributes # ~/.gitattributes
scope: text.git.attributes

contexts:

Expand Down Expand Up @@ -59,7 +61,7 @@ contexts:
- meta_scope: string.unquoted.git.attributes
- meta_content_scope: entity.name.pattern.git.attributes
- match: (?=\s)
pop: true
pop: 1
- include: Git Common.sublime-syntax#fnmatch-body

pattern-attributes:
Expand All @@ -74,7 +76,7 @@ contexts:
# attriubte list ends with line
- match: $\n?
scope: meta.attributes-list.git.attributes
pop: true
pop: 1
# set/unset operators
- match: '[-!](?=\w)'
scope: keyword.operator.logical.git.attributes
Expand Down Expand Up @@ -154,10 +156,10 @@ contexts:
attribute-maybe-value-list:
- meta_content_scope: meta.mapping.git.attributes
- match: =(?=\S)
scope: punctuation.separator.mapping.key-value.git.attributes
scope: meta.mapping.git.attributes punctuation.separator.mapping.key-value.git.attributes
set: [attribute-value-list, attribute-value-content]
- match: =
scope: punctuation.separator.mapping.key-value.git.attributes
scope: meta.mapping.git.attributes punctuation.separator.mapping.key-value.git.attributes
set: attribute-value-expected
- include: attribute-separator
- include: immediately-pop
Expand All @@ -169,7 +171,7 @@ contexts:
scope: punctuation.separator.mapping.values.git.attributes
push: attribute-value-content
- match: ','
scope: punctuation.separator.mapping.values.git.attributes
scope: meta.mapping.git.attributes punctuation.separator.mapping.values.git.attributes
set: attribute-value-expected
- match: \S
scope: invalid.illegal.value.git.attributes
Expand All @@ -183,22 +185,22 @@ contexts:
# unquoted value is everything except , and whitespace
- match: '[^,\s]*'
scope: meta.string.git.attributes string.unquoted.git.attributes
pop: true
pop: 1
- include: immediately-pop

attribute-value-expected:
# Attributes are separated by whitespace
# One whitespace after each attribute/value is captured as separator
- match: \s
scope: meta.mapping.expect-value.git.attributes punctuation.separator.mapping.pair.git.attributes
pop: true
pop: 1

attribute-separator:
# Attributes are separated by whitespace
# One whitespace after each attribute/value is captured as separator
- match: \s
scope: meta.mapping.git.attributes punctuation.separator.mapping.pair.git.attributes
pop: true
pop: 1

##[ PROTOTYPES ]#######################################################

Expand All @@ -212,11 +214,11 @@ contexts:
string-end:
- match: \"
scope: punctuation.definition.string.end.git.attributes
pop: true
pop: 1
- match: \n
scope: invalid.illegal.unexpected.eol.git.attributes
pop: true
pop: 1

immediately-pop:
- match: ''
pop: true
pop: 1
8 changes: 5 additions & 3 deletions Git Formats/Git Commit.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
# Highlight regular git commits, merge commits, and tags.

name: Git Commit
scope: text.git.commit
version: 2

file_extensions:
- COMMIT_EDITMSG
- MERGE_MSG
- TAG_EDITMSG
scope: text.git.commit

variables:
comment_char: '[#;]'
Expand Down Expand Up @@ -72,7 +74,7 @@ contexts:
- meta_include_prototype: false
- meta_scope: meta.message.git.commit
- match: ^(?=#)
pop: true
pop: 1
- include: Git Common.sublime-syntax#references
- include: signed-off

Expand All @@ -91,7 +93,7 @@ contexts:
- meta_include_prototype: false
- meta_scope: comment.line.git.commit
- match: $\n?
pop: true
pop: 1
- include: branch-line
- include: change-list
- include: commands-line
Expand Down
48 changes: 25 additions & 23 deletions Git Formats/Git Common.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# This file is some kind of internal library which is used to store
# common rules which are used by the visible syntax files.
name: Git Common
hidden: true
scope: text.git.common
version: 2
hidden: true

variables:
comment_char: '[#;]'
Expand All @@ -29,18 +30,18 @@ contexts:
# make sure to resume parsing at next line
push:
- match: (?=\S|^\s*$)
pop: true
pop: 1

eol-pop:
- include: line-continuation
- match: $
pop: true
pop: 1

illegal-eol-pop:
- include: line-continuation
- match: $\n?
scope: invalid.illegal.unexpected.eol.git
pop: true
pop: 1

##[ COMMENTS ]#########################################################

Expand Down Expand Up @@ -97,14 +98,15 @@ contexts:
push: [email-meta, email-name]

email-meta:
- meta_include_prototype: false
- meta_scope: meta.reference.email.git
- match: ''
pop: true
pop: 1

email-name:
- meta_content_scope: entity.name.reference.email.git
- match: '@'
scope: punctuation.separator.email.git
scope: entity.name.reference.email.git punctuation.separator.email.git
set: email-domain
- include: email-end

Expand All @@ -117,7 +119,7 @@ contexts:
email-end:
- match: '>'
scope: punctuation.definition.reference.email.end.git
pop: true
pop: 1

username:
# user reference
Expand All @@ -143,11 +145,11 @@ contexts:
- match: '[A-Za-z](:)(?=/)'
captures:
1: punctuation.separator.drive.fnmatch.git
pop: true
pop: 1
# homedir tilde operator
- match: ~(?=/)
scope: variable.language.environment.home.fnmatch.git
pop: true
pop: 1
# any other directory pattern
- include: fnmatch-dir-pattern

Expand Down Expand Up @@ -181,31 +183,31 @@ contexts:
fnmatch-dir-pattern:
- match: \.\.(?=/)
scope: constant.language.path.parent.fnmatch.git
pop: true
pop: 1
- match: \.(?=/)
scope: constant.language.path.self.fnmatch.git
pop: true
pop: 1
- match: ''
pop: true
pop: 1

fnmatch-char-class-operator:
- match: '[!^]?' # optional pattern negation
scope: keyword.operator.logical.fnmatch.git
pop: true
pop: 1

fnmatch-char-class-start:
- match: \]? # first unescaped ']' is matched as normal char
scope: constant.character.char-class.fnmatch.git
pop: true
pop: 1

fnmatch-char-class-body:
- meta_scope: meta.char-class.fnmatch.git
- match: \]
scope: keyword.control.char-class.end.fnmatch.git
pop: true
pop: 1
- match: $\n? # class must end before end of line
scope: invalid.illegal.unexpected.eol.fnmatch.git
pop: true
pop: 1
- match: '\\\]' # backslash escapes only ']'
scope: constant.character.escape.char-class.fnmatch.git
- match: '[*?]' # asterisk is ignored by fnmatch
Expand Down Expand Up @@ -244,7 +246,7 @@ contexts:
include-pretty-formats:
- meta_content_scope: meta.pretty-formats.git
- match: (?!\S)
pop: true
pop: 1
- match: (\')(?:(t?format)(:))?
captures:
1: punctuation.definition.string.begin.shell
Expand All @@ -254,7 +256,7 @@ contexts:
- meta_scope: string.quoted.single.shell
- match: \'
scope: punctuation.definition.string.end.shell
pop: true
pop: 1
- include: illegal-eol-pop
- include: pretty-formats
- match: \"(?:(t?format)(:))?
Expand All @@ -266,7 +268,7 @@ contexts:
- meta_scope: string.quoted.double.shell
- match: \"
scope: punctuation.definition.string.end.shell
pop: true
pop: 1
- include: illegal-eol-pop
- include: pretty-formats
- include: pretty-formats
Expand Down Expand Up @@ -301,7 +303,7 @@ contexts:
- meta_content_scope: meta.function-call.arguments.pretty-formats.git
- match: '\)'
scope: meta.function-call.arguments.pretty-formats.git punctuation.section.parens.end.pretty-formats.git
pop: true
pop: 1
- match: \d+
scope: meta.number.integer.decimal.git constant.numeric.value.git
- match: ',,'
Expand Down Expand Up @@ -345,7 +347,7 @@ contexts:
- meta_content_scope: meta.function-call.arguments.pretty-formats.git
- match: \)
scope: meta.function-call.arguments.pretty-formats.git punctuation.section.parens.end.pretty-formats.git
pop: true
pop: 1
- include: Git Config.sublime-syntax#color-value
- match: reset
scope: support.constant.color-reset.git.config
Expand All @@ -360,13 +362,13 @@ contexts:
- include: illegal-eol-pop
- match: \)
scope: punctuation.section.parens.end.pretty-formats.git
pop: true
pop: 1
- match: ':'
scope: keyword.operator.assignment.option.pretty-formats.git
push:
- include: eol-pop
- match: (?=\))
pop: true
pop: 1
- match: ',,|:'
scope: invalid.illegal.pretty-formats.git
- match: ','
Expand Down
21 changes: 12 additions & 9 deletions Git Formats/Git Config.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
# https://git-scm.com/docs/git-config#_syntax

name: Git Config
scope: text.git.config
version: 2

file_extensions:
- gitconfig # /etc/gitconfig
- .gitconfig # ~/.gitconfig
- .gitmodules # ~/.gitmodules

first_line_match: ^\[core\] # .git/config files always start with [core]
scope: text.git.config

variables:
variable_name: '[a-zA-Z][\w-]*'
Expand Down Expand Up @@ -44,7 +47,7 @@ contexts:
- meta_scope: meta.brackets.git.config
- match: \]
scope: punctuation.definition.brackets.end.git.config
pop: true
pop: 1
- include: illegal-line-end-pop
- match: \S
scope: invalid.illegal.header-end.git.config
Expand All @@ -59,7 +62,7 @@ contexts:
scope: punctuation.accessor.dot.git.config
set: subsection-name-unquoted
- match: (?=\])
pop: true
pop: 1
- include: illegal-line-end-pop
- match: \S
scope: invalid.illegal.section-name.git.config
Expand All @@ -70,7 +73,7 @@ contexts:
- meta_scope: string.quoted.double.git.config
- match: \"
scope: punctuation.definition.string.end.git.config
pop: true
pop: 1
- match: \\[\\"]
scope: constant.character.escape.git.config
# `\` is legal, but it can lead to confusion because escapes like `\t`
Expand All @@ -87,14 +90,14 @@ contexts:
- match: \.
scope: punctuation.accessor.dot.git.config
- match: (?=\])
pop: true
pop: 1
- include: illegal-line-end-pop
- match: \S
scope: invalid.illegal.subsection-name.git.config

expect-section:
- match: (?=^\s*\[) # start of new section
pop: true
pop: 1
- match: \]
scope: punctuation.definition.brackets.end.git.config invalid.illegal.stray-bracket.git.config

Expand Down Expand Up @@ -212,11 +215,11 @@ contexts:
# make sure to resume parsing at next line
push:
- match: (?=\S|^\s*$)
pop: true
pop: 1

line-end:
- match: $
pop: true
pop: 1

expect-line-end:
- include: line-end
Expand All @@ -232,4 +235,4 @@ contexts:
illegal-line-end-pop:
- match: $\n?
scope: invalid.illegal.unexpected.eol.git.config
pop: true
pop: 1
Loading