Skip to content

Commit abffe22

Browse files
committed
Merge branch 'master' into pr/shellscript/fix-qualifiers
2 parents 8b9304b + 9072a68 commit abffe22

27 files changed

+968
-228
lines changed

C#/C#.sublime-syntax

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ file_extensions:
1414

1515
first_line_match: |-
1616
(?xi:
17-
^ \s* // .*? -\*- .*? \b(c\#|cs|csharp)\b .*? -\*- # editorconfig
17+
^ \#! .* {{shebang_language}} # shebang
18+
| ^ \s* // .*? -\*- .*? \b(c\#|cs|csharp)\b .*? -\*- # editorconfig
1819
)
1920
2021
variables:
22+
shebang_language: \bdotnet\s+run\b
2123

2224
bin_op: '(?:\+|->|-|\*|/|%|\|\||&&|\||&|\^|<<|>>|=>|<=|<|>=|>|==|!=|\?\?)'
2325
unary_op: '(?:\+\+|--|-|~|!|&|\*)'
@@ -59,6 +61,11 @@ contexts:
5961
2: punctuation.definition.preprocessor.cs
6062
push: preprocessor_option
6163

64+
main:
65+
- meta_include_prototype: false
66+
- match: ''
67+
push: [statements, shebang]
68+
6269
# comments
6370
comments:
6471
- match: '^\s*(///)'
@@ -192,8 +199,11 @@ contexts:
192199
1: keyword.other.preprocessor.cs
193200
2: keyword.other.preprocessor.cs
194201
3: keyword.other.preprocessor.cs
195-
- match: .*
196-
scope: invalid.illegal.cs
202+
203+
- match: (:)(\w+)
204+
captures:
205+
1: punctuation.definition.preprocessor.cs
206+
2: variable.language.cs
197207
- match: $
198208
pop: true
199209

@@ -217,6 +227,23 @@ contexts:
217227
3: variable.other.section.cs
218228
4: meta.fold.end.cs
219229

230+
shebang:
231+
- meta_include_prototype: false
232+
- match: ^\s*(\#!)
233+
captures:
234+
1: punctuation.definition.comment.cs
235+
set: shebang-body
236+
- match: ^|(?=\S) # Note: Ensure to highlight shebang if C# is embedded.
237+
pop: 1
238+
239+
shebang-body:
240+
- meta_include_prototype: false
241+
- meta_scope: comment.line.shebang.cs
242+
- match: '{{shebang_language}}'
243+
scope: constant.language.shebang.cs
244+
- match: $\n?
245+
pop: 1
246+
220247
# Pops out at the end of the line and handles comments.
221248
# Marks the rest of the line as invalid.
222249
option_done:
@@ -226,7 +253,7 @@ contexts:
226253
- match: \S
227254
scope: invalid.illegal.cs
228255

229-
main:
256+
statements:
230257
- include: stray_close_bracket
231258
- match: '\{'
232259
scope: punctuation.section.block.begin.cs
@@ -235,7 +262,7 @@ contexts:
235262
- match: '\}'
236263
scope: punctuation.section.block.end.cs
237264
pop: true
238-
- include: main
265+
- include: statements
239266
- include: attribute
240267
- include: using
241268
- include: class_declaration
@@ -351,7 +378,7 @@ contexts:
351378
- match: \}
352379
scope: punctuation.section.block.end.cs
353380
pop: true
354-
- include: main
381+
- include: statements
355382

356383
class_declaration:
357384
- match: \b(static|unsafe|abstract|partial|readonly|required|sealed)\b

C#/Indentation Rules.tmPreferences

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@
2020
[^}"']* # followed by any number of characters that isn't a close brace or a string
2121
$ # the end of the line
2222
</string>
23-
<key>indentNextLinePattern</key>
24-
<string>(?x)^
25-
(?! .* [;:{}] # do not indent when line ends with ;, :, {, or }
26-
\s* (//|/[*] .* [*]/ \s* $) # …account for potential trailing comment
27-
)
28-
.* [^\s;:{}] \s* $ # indent next if this one isn’t
29-
# terminated with ;, :, {, or }
30-
</string>
3123
<key>unIndentedLinePattern</key>
3224
<string>^\s*((/\*|\*/|//|#).*)?$</string>
3325
</dict>

C#/tests/syntax_test_dotnetrun.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#! SYNTAX TEST "Packages/C#/C#.sublime-syntax" dotnet run
2+
#! <- comment.line.shebang.cs punctuation.definition.comment.cs
3+
#!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.shebang.cs
4+
#! ^^^^^^^^^^ constant.language.shebang.cs
5+
6+
// https://devblogs.microsoft.com/dotnet/announcing-dotnet-run-app/
7+
8+
#:package Humanizer@2.14.1
9+
#!^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.cs
10+
#!^^^^^^^ variable.language.cs
11+
#! ^^^^^^^^^^^^^^^^^ - variable - invalid
12+
#:sdk Microsoft.NET.Sdk.Web
13+
#!^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.cs
14+
#!^^^ variable.language.cs
15+
#! ^^^^^^^^^^^^^^^^^^^^^^^ - variable - invalid
16+
#:property LangVersion preview
17+
#!^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.cs
18+
#!^^^^^^^^ variable.language.cs
19+
#! ^^^^^^^^^^^^^^^^^^^^^ - variable - invalid
20+
21+
#:package Microsoft.AspNetCore.OpenApi@10.*-*
22+
#!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.cs
23+
#!^ keyword.other.preprocessor.cs punctuation.definition.preprocessor.cs
24+
#! ^ punctuation.definition.preprocessor.cs
25+
#! ^^^^^^^ variable.language.cs
26+
27+
28+
var builder = WebApplication.CreateBuilder();
29+
#! ^^^^^^^ variable.other.cs
30+
#! ^ keyword.operator.assignment.variable.cs
31+
#! ^^^^^^^^^^^^^^ variable.other.cs
32+
#! ^ punctuation.accessor.dot.cs
33+
#! ^^^^^^^^^^^^^^^ meta.function-call.cs
34+
#! ^^^^^^^^^^^^^ variable.function.cs
35+
#! ^^ meta.group.cs
36+
#! ^ punctuation.section.group.begin.cs
37+
#! ^ punctuation.section.group.end.cs
38+
#! ^ punctuation.terminator.statement.cs
39+
40+
builder.Services.AddOpenApi();
41+
42+
var app = builder.Build();
43+
44+
app.MapGet("/", () => "Hello, world!");
45+
app.Run();

Git Formats/Git Diff.sublime-syntax

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ contexts:
392392
# Combined mode can have multiple pre-commits
393393
- include: separator-comma
394394

395+
- include: pop-before-diff-header
396+
395397
diff-content:
396398
- meta_content_scope: meta.block.delta.diff
397399
- include: pop-before-diff-header

0 commit comments

Comments
 (0)