Skip to content

Commit 0dc960e

Browse files
authored
[Git Config] Some scope tweaks (sublimehq#4171)
* [Git Config] Simplify section scopes This commit simplifies `meta.section` scopes by. 1. removing `meta.section.body` from key-value pairs, which also covered section headers illegally 2. strip `.header` sub scope. As a result, only lines with `[section "subsection"]` are scoped meta.section.git.config, which is also true for INI and TOML. * [Git Config] Tweak key scopes This commit applies `meta.mapping.key string.unquoted` to keys. * [Git Config] Scope whole line meta.section This commit ensures to also scope leading whitespace meta.section, so possibly applied background color covers full width of a view. * [Git Config] Fix brackets punctuation scope This commit uses punctuation.section.brackets according to scope naming guidelines. * [Git Formats] Fix symbol list --------- Co-authored-by: deathaxe <[email protected]>
1 parent 194c082 commit 0dc960e

File tree

4 files changed

+95
-93
lines changed

4 files changed

+95
-93
lines changed

Git Formats/Git Config - Fold.tmPreferences

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
<array>
1010
<dict>
1111
<key>begin</key>
12-
<string>meta.section meta.brackets punctuation.definition.brackets.end</string>
12+
<string>meta.section meta.brackets punctuation.section.brackets.end</string>
1313
<key>end</key>
14-
<string>meta.section meta.brackets punctuation.definition.brackets.begin</string>
14+
<string>meta.section meta.brackets punctuation.section.brackets.begin</string>
1515
<key>excludeTrailingNewlines</key>
1616
<true/>
1717
</dict>

Git Formats/Git Config - Symbol List.tmPreferences

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<key>name</key>
55
<string>Symbol List</string>
66
<key>scope</key>
7-
<string>meta.section.header.git.config meta.brackets.git.config</string>
7+
<string>meta.section.git.config meta.brackets.git.config</string>
88
<key>settings</key>
99
<dict>
1010
<key>showInSymbolList</key>

Git Formats/Git Config.sublime-syntax

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ hidden_file_extensions:
1717
first_line_match: ^\[core\] # .git/config files always start with [core]
1818

1919
variables:
20-
variable_name: '[a-zA-Z][\w-]*'
20+
key_name: '[a-zA-Z][\w-]*'
2121
zero_to_255: 25[0-5]|2[0-4][0-9]|1\d\d|[1-9][0-9]|[0-9]
2222

2323
contexts:
@@ -33,20 +33,20 @@ contexts:
3333
# Note that this does not match [color] (without the subsection). This is
3434
# because [color] doesn't actually take color values.
3535
- match: ^\s*(?=\[\s*color\s+\")
36-
push: [key-color-pair, section-header]
36+
push: [key-color-pair, section-header-meta, section-header]
3737
# section-other matches all sections except [color "subsection"].
3838
- match: ^\s*(?=\[)
39-
push: [key-value-pair, section-header]
39+
push: [key-value-pair, section-header-meta, section-header]
4040

4141
###[ SECTION HEADERS ]#########################################################
4242

4343
section-header:
4444
- match: \[
45-
scope: punctuation.definition.brackets.begin.git.config
46-
set: [section-header-meta, section-header-end, section-name]
45+
scope: punctuation.section.brackets.begin.git.config
46+
set: [section-header-end, section-name]
4747

4848
section-header-meta:
49-
- meta_scope: meta.section.header.git.config
49+
- meta_scope: meta.section.git.config
5050
- match: $\n?
5151
pop: 1
5252
- match: \S
@@ -55,7 +55,7 @@ contexts:
5555
section-header-end:
5656
- meta_scope: meta.brackets.git.config
5757
- match: \]
58-
scope: punctuation.definition.brackets.end.git.config
58+
scope: punctuation.section.brackets.end.git.config
5959
pop: 1
6060
- include: illegal-line-end-pop
6161
- match: \S
@@ -115,11 +115,10 @@ contexts:
115115
# changed = red
116116
# untracked = bold green
117117
key-color-pair:
118-
- meta_scope: meta.section.body.git.config
119-
- match: ^(\s*)({{variable_name}})(\s*(\=)\s*)
118+
- match: ^(\s*)({{key_name}})(\s*(=)\s*)
120119
captures:
121120
1: meta.mapping.git.config
122-
2: meta.mapping.key.git.config variable.other.readwrite.git.config
121+
2: meta.mapping.key.git.config string.unquoted.git.config
123122
3: meta.mapping.git.config
124123
4: punctuation.separator.key-value.git.config
125124
push:
@@ -130,11 +129,10 @@ contexts:
130129

131130
# key = val
132131
key-value-pair:
133-
- meta_scope: meta.section.body.git.config
134-
- match: ^(\s*)({{variable_name}})(\s*(\=)\s*)
132+
- match: ^(\s*)({{key_name}})(\s*(=)\s*)
135133
captures:
136134
1: meta.mapping.git.config
137-
2: meta.mapping.key.git.config variable.other.readwrite.git.config
135+
2: meta.mapping.key.git.config string.unquoted.git.config
138136
3: meta.mapping.git.config
139137
4: punctuation.separator.key-value.git.config
140138
push:

0 commit comments

Comments
 (0)