Skip to content

Commit b453f26

Browse files
vpetrovykh1st1
authored andcommitted
Highlight . in its own scope. (#101)
The scope for `.` is `punctuation.separator.period.python`.
1 parent dcb1a38 commit b453f26

35 files changed

+493
-392
lines changed

Diff for: grammars/MagicPython.cson

+11-3
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ repository:
386386
}
387387
]
388388
"member-access":
389-
begin: "\\.\\s*(?!\\.)"
389+
begin: "(\\.)\\s*(?!\\.)"
390390
end: '''
391391
(?x)
392392
# stop when you've just read non-whitespace followed by non-word
@@ -398,6 +398,9 @@ repository:
398398
$
399399
400400
'''
401+
beginCaptures:
402+
"1":
403+
name: "punctuation.separator.period.python"
401404
patterns: [
402405
{
403406
include: "#function-call"
@@ -995,12 +998,14 @@ repository:
995998
{
996999
match: '''
9971000
(?x)
998-
\\s* \\b(from)\\b (\\s*\\.+\\s*) (import)?
1001+
\\s* \\b(from)\\b \\s*(\\.+)\\s* (import)?
9991002
10001003
'''
10011004
captures:
10021005
"1":
10031006
name: "keyword.control.import.python"
1007+
"2":
1008+
name: "punctuation.separator.period.python"
10041009
"3":
10051010
name: "keyword.control.import.python"
10061011
}
@@ -1122,8 +1127,11 @@ repository:
11221127
"1":
11231128
name: "entity.other.inherited-class.python"
11241129
"member-access-class":
1125-
begin: "\\.\\s*(?!\\.)"
1130+
begin: "(\\.)\\s*(?!\\.)"
11261131
end: "(?<=\\S)(?=\\W)|$"
1132+
beginCaptures:
1133+
"1":
1134+
name: "punctuation.separator.period.python"
11271135
patterns: [
11281136
{
11291137
include: "#call-wrapper-inheritance"

Diff for: grammars/MagicPython.tmLanguage

+24-3
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@
589589
<key>member-access</key>
590590
<dict>
591591
<key>begin</key>
592-
<string>\.\s*(?!\.)</string>
592+
<string>(\.)\s*(?!\.)</string>
593593
<key>end</key>
594594
<string>(?x)
595595
# stop when you've just read non-whitespace followed by non-word
@@ -600,6 +600,14 @@
600600
(^|(?&lt;=\s))(?=[^\\\w\s]) |
601601
$
602602
</string>
603+
<key>beginCaptures</key>
604+
<dict>
605+
<key>1</key>
606+
<dict>
607+
<key>name</key>
608+
<string>punctuation.separator.period.python</string>
609+
</dict>
610+
</dict>
603611
<key>patterns</key>
604612
<array>
605613
<dict>
@@ -1513,7 +1521,7 @@
15131521
<dict>
15141522
<key>match</key>
15151523
<string>(?x)
1516-
\s* \b(from)\b (\s*\.+\s*) (import)?
1524+
\s* \b(from)\b \s*(\.+)\s* (import)?
15171525
</string>
15181526
<key>captures</key>
15191527
<dict>
@@ -1522,6 +1530,11 @@
15221530
<key>name</key>
15231531
<string>keyword.control.import.python</string>
15241532
</dict>
1533+
<key>2</key>
1534+
<dict>
1535+
<key>name</key>
1536+
<string>punctuation.separator.period.python</string>
1537+
</dict>
15251538
<key>3</key>
15261539
<dict>
15271540
<key>name</key>
@@ -1719,9 +1732,17 @@
17191732
<key>member-access-class</key>
17201733
<dict>
17211734
<key>begin</key>
1722-
<string>\.\s*(?!\.)</string>
1735+
<string>(\.)\s*(?!\.)</string>
17231736
<key>end</key>
17241737
<string>(?&lt;=\S)(?=\W)|$</string>
1738+
<key>beginCaptures</key>
1739+
<dict>
1740+
<key>1</key>
1741+
<dict>
1742+
<key>name</key>
1743+
<string>punctuation.separator.period.python</string>
1744+
</dict>
1745+
</dict>
17251746
<key>patterns</key>
17261747
<array>
17271748
<dict>

Diff for: grammars/src/MagicPython.syntax.yaml

+8-3
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ repository:
415415
match: (?x) \b ([[:alpha:]_]\w*) \b
416416

417417
member-access:
418-
begin: \.\s*(?!\.)
418+
begin: (\.)\s*(?!\.)
419419
end: |
420420
(?x)
421421
# stop when you've just read non-whitespace followed by non-word
@@ -425,6 +425,8 @@ repository:
425425
# i.e. when seeing a non-identifier
426426
(^|(?<=\s))(?=[^\\\w\s]) |
427427
$
428+
beginCaptures:
429+
'1': {name: punctuation.separator.period.python}
428430
patterns:
429431
- include: '#function-call'
430432
- include: '#member-access-base'
@@ -829,9 +831,10 @@ repository:
829831
patterns:
830832
- match: |
831833
(?x)
832-
\s* \b(from)\b (\s*\.+\s*) (import)?
834+
\s* \b(from)\b \s*(\.+)\s* (import)?
833835
captures:
834836
'1': {name: keyword.control.import.python}
837+
'2': {name: punctuation.separator.period.python}
835838
'3': {name: keyword.control.import.python}
836839
- name: keyword.control.import.python
837840
match: \b(?<!\.)import\b
@@ -907,8 +910,10 @@ repository:
907910
'1': {name: entity.other.inherited-class.python}
908911

909912
member-access-class:
910-
begin: \.\s*(?!\.)
913+
begin: (\.)\s*(?!\.)
911914
end: (?<=\S)(?=\W)|$
915+
beginCaptures:
916+
'1': {name: punctuation.separator.period.python}
912917
patterns:
913918
- include: '#call-wrapper-inheritance'
914919
- include: '#member-access-base'

Diff for: misc/scopes

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ punctuation.separator.dict.python
120120
punctuation.separator.element.python
121121
punctuation.separator.inheritance.python
122122
punctuation.separator.parameters.python
123+
punctuation.separator.period.python
123124
punctuation.separator.slice.python
124125
storage.modifier.declaration.python
125126
storage.modifier.flag.regexp

0 commit comments

Comments
 (0)