Skip to content

Commit

Permalink
Merge pull request #59 from dkearns/highlight-record-keyword
Browse files Browse the repository at this point in the history
Highlight record as a keyword
  • Loading branch information
dkearns authored Jun 19, 2022
2 parents 19db2b7 + e610a43 commit 3b075e0
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
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)

0 comments on commit 3b075e0

Please sign in to comment.