%YAML 1.2
---
name: Git Config
file_extensions:
- gitconfig
- gitmodules
scope: source.gitconfig
contexts:
main:
- include: comments
- include: sections
- include: key-value
comments:
- match: '^[#;].*$'
scope: comment.line.gitconfig
- match: '\s+[#;].*$'
scope: comment.line.gitconfig
sections:
- match: '^\s*(\[)([^\]\s"]+)(?:\s+"([^"]+)")?(\])'
captures:
1: punctuation.definition.section.begin.gitconfig
2: entity.name.section.gitconfig
3: string.quoted.double.subsection.gitconfig
4: punctuation.definition.section.end.gitconfig
key-value:
- match: '^\s*([a-zA-Z][a-zA-Z0-9_-]*)\s*(=)'
captures:
1: variable.other.key.gitconfig
2: punctuation.separator.key-value.gitconfig
push: value
value:
- include: strings
- include: booleans
- include: numbers
- include: colors
- match: '$'
pop: true
strings:
- match: '"'
scope: punctuation.definition.string.begin.gitconfig
push:
- meta_scope: string.quoted.double.gitconfig
- match: '\\.'
scope: constant.character.escape.gitconfig
- match: '"'
scope: punctuation.definition.string.end.gitconfig
pop: true
- match: '\S+'
scope: string.unquoted.gitconfig
booleans:
- match: '\b(true|false|yes|no|on|off)\b'
scope: constant.language.boolean.gitconfig
numbers:
- match: '\b\d+[kKmMgG]?\b'
scope: constant.numeric.gitconfig
colors:
- match: '\b(normal|black|red|green|yellow|blue|magenta|cyan|white|default|bold|dim|ul|blink|reverse|italic|strike|bright\w+)\b'
scope: support.constant.color.gitconfig