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

[D] Add bracket fold rules and reenable indentation folding #3879

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions D/D.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -814,11 +814,13 @@ contexts:
- match: '(?=\S)'
pop: true
basic-type2-after-brackets:
- meta_scope: meta.brackets.d
- match: '\]'
scope: punctuation.section.brackets.end.d
pop: true
- include: not-whitespace-illegal-pop
basic-type2-after-parens:
- meta_scope: meta.parens.d
- match: '\)'
scope: punctuation.section.parens.end.d
pop: true
Expand Down Expand Up @@ -1110,11 +1112,13 @@ contexts:
- match: '(?=\S)'
set: [value-list-after, value-after]
first-value-bracket-after:
- meta_scope: meta.brackets.d
- match: '\]'
scope: punctuation.section.brackets.end.d
set: first-value-after
- include: not-whitespace-illegal-pop
first-value-parens-after:
- meta_scope: meta.parens.d
- match: '\)'
scope: punctuation.section.parens.end.d
set: first-value-after
Expand Down Expand Up @@ -1492,6 +1496,7 @@ contexts:
set: value-after
- include: not-whitespace-illegal-pop
value-bracket-after:
- meta_scope: meta.brackets.d
- match: '\]'
scope: punctuation.section.brackets.end.d
set: value-after
Expand Down
10 changes: 9 additions & 1 deletion D/Fold.tmPreferences
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<key>settings</key>
<dict>
<key>indentationFoldingEnabled</key>
<false/>
<true/>
<key>foldScopes</key>
<array>
<dict>
Expand All @@ -15,6 +15,14 @@
<key>end</key>
<string>punctuation.section.block.end</string>
</dict>
<dict>
<key>begin</key>
<string>punctuation.section.brackets.begin</string>
<key>end</key>
<string>punctuation.section.brackets.end</string>
<key>excludeTrailingNewlines</key>
<false/>
</dict>
</array>
</dict>
</dict>
Expand Down
11 changes: 11 additions & 0 deletions D/tests/syntax_test_d.d
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ extern(1)
// ^ keyword.operator.assignment.d
// ^^^^^ storage.modifier.d
// ^^^ storage.type.d
// ^^^^^^^^ meta.brackets.d
// ^ punctuation.section.brackets.begin.d
// ^^^^^^ storage.type.d
// ^ punctuation.section.brackets.end.d
Expand All @@ -598,6 +599,7 @@ extern(1)
//^^^^^ keyword.control.alias.d
// ^^^^^ storage.modifier.d
// ^^^ storage.type.d
// ^^^^^^^^ meta.brackets.d
// ^ punctuation.section.brackets.begin.d
// ^^^^^^ storage.type.d
// ^ punctuation.section.brackets.end.d
Expand Down Expand Up @@ -648,6 +650,7 @@ extern(1)
// ^ punctuation.terminator.d
foo[string] b = 123;
//^^^ storage.type.d
// ^^^^^^^^ meta.brackets.d
// ^ punctuation.section.brackets.begin.d
// ^^^^^^ storage.type.d
// ^ punctuation.section.brackets.end.d
Expand All @@ -667,6 +670,7 @@ extern(1)
// ^ punctuation.terminator.d
foo[BAR] baz;
//^^^ storage.type.d
// ^^^^^ meta.brackets.d
// ^ punctuation.section.brackets.begin.d
// ^^^ variable.other.d
// ^ punctuation.section.brackets.end.d
Expand Down Expand Up @@ -958,6 +962,7 @@ extern(1)
//^^^^ keyword.declaration.enum.d
// ^ punctuation.separator.mapping.d
// ^^^ storage.type.d
// ^^^^^^^^ meta.brackets.d
// ^ punctuation.section.brackets.begin.d
// ^^^^^^ storage.type.d
// ^ punctuation.section.brackets.end.d
Expand Down Expand Up @@ -1240,6 +1245,7 @@ extern(1)

int[string] foo() {}
//^^^ storage.type.d
// ^^^^^^^^ meta.brackets.d
// ^ punctuation.section.brackets.begin.d
// ^^^^^^ storage.type.d
// ^ punctuation.section.brackets.end.d
Expand Down Expand Up @@ -2252,6 +2258,7 @@ extern(1)
// ^^^^^ string.quoted.double.d
// ^ punctuation.section.parens.end.d
// ^^^^^^ storage.type.d
// ^^^^ meta.brackets.d
// ^ punctuation.section.brackets.begin.d
// ^^ meta.number.integer.decimal.d
// ^ punctuation.section.brackets.end.d
Expand Down Expand Up @@ -2283,6 +2290,7 @@ extern(1)
// ^ meta.number.integer.decimal.d
// ^ punctuation.section.parens.end.d
// ^^^^^^ storage.type.d
// ^^^^ meta.brackets.d
// ^ punctuation.section.brackets.begin.d
// ^^ meta.number.integer.decimal.d
// ^ punctuation.section.brackets.end.d
Expand Down Expand Up @@ -2393,6 +2401,7 @@ extern(1)
// ^^^ variable.other.d
// ^ keyword.operator.arithmetic.d
// ^^^ variable.other.d
// ^^^^^^^^^^ meta.brackets.d
// ^ punctuation.section.brackets.begin.d
// ^^^ variable.other.d
// ^ keyword.operator.arithmetic.d
Expand Down Expand Up @@ -3119,6 +3128,7 @@ extern(1)

void[int**]* foo;
//^^^^ storage.type.d
// ^^^^^^^ meta.brackets.d
// ^ punctuation.section.brackets.begin.d
// ^^^ storage.type.d
// ^^ keyword.operator.pointer.d
Expand All @@ -3143,6 +3153,7 @@ extern(1)
// ^ punctuation.section.block.end.d
a[b] * c;
//^ meta.path.d variable.other.d
// ^^^ meta.brackets.d
// ^ punctuation.section.brackets.begin.d
// ^ meta.path.d variable.other.d
// ^ punctuation.section.brackets.end.d
Expand Down