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

Highlight record as a keyword #59

Merged
merged 1 commit into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions syntax/cs.vim
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ syn keyword csType bool byte char decimal double float int long object sbyte sho
syn keyword csType nint nuint " contextual

syn keyword csStorage enum interface namespace struct
syn match csStorage "\<record\ze\_s\+@\=\h\w*\_s*[<(:{;]"
syn match csStorage "\%(\<\%(partial\|new\|public\|protected\|internal\|private\|abstract\|sealed\|static\|unsafe\|readonly\)\)\@9<=\_s\+record\>"
syn match csStorage "\<record\ze\_s\+\%(class\|struct\)"
syn match csStorage "\<delegate\>"
syn keyword csRepeat break continue do for foreach goto return while
syn keyword csConditional else if switch
Expand Down
67 changes: 67 additions & 0 deletions test/records.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Given cs (record matching via body):
record Foo {}
record struct Foo {}
record class Foo {}

Execute:
AssertEqual 'csStorage', SyntaxOf('record', 1)
AssertEqual 'csStorage', SyntaxOf('record', 2)
AssertEqual 'csStorage', SyntaxOf('record', 3)

Given cs (record matching via body):
record Foo;
record struct Foo;
record class Foo;

Execute:
AssertEqual 'csStorage', SyntaxOf('record', 1)
AssertEqual 'csStorage', SyntaxOf('record', 2)
AssertEqual 'csStorage', SyntaxOf('record', 3)

Given cs (record matching via type parameter list):
record Foo<T>;
record struct Foo<T>;
record class Foo<T>;

Execute:
AssertEqual 'csStorage', SyntaxOf('record', 1)
AssertEqual 'csStorage', SyntaxOf('record', 2)
AssertEqual 'csStorage', SyntaxOf('record', 3)

Given cs (record matching via parameter list):
record Foo(int X, int Y);
record struct Foo(int X, int Y);
record class Foo(int X, int Y);

Execute:
AssertEqual 'csStorage', SyntaxOf('record', 1)
AssertEqual 'csStorage', SyntaxOf('record', 2)
AssertEqual 'csStorage', SyntaxOf('record', 3)

Given cs (record matching via base type):
record Foo : Bar;
record struct Foo : Bar;
record class Foo : Bar;

Execute:
AssertEqual 'csStorage', SyntaxOf('record', 1)
AssertEqual 'csStorage', SyntaxOf('record', 2)
AssertEqual 'csStorage', SyntaxOf('record', 3)

Given cs (record matching via modifier):
partial record Foo ...
partial record struct ...
partial record class ...

Execute:
AssertEqual 'csStorage', SyntaxOf('record', 1)
AssertEqual 'csStorage', SyntaxOf('record', 2)
AssertEqual 'csStorage', SyntaxOf('record', 3)

Given cs (record matching via class or struct):
record struct ...
record class ...

Execute:
AssertEqual 'csStorage', SyntaxOf('record', 1)
AssertEqual 'csStorage', SyntaxOf('record', 2)