Skip to content

Commit

Permalink
fix up function/parameter handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kortschak committed Feb 21, 2022
1 parent c4cbfe1 commit f58bc37
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
28 changes: 10 additions & 18 deletions Go/Go.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ variables:
ident: \b(?!{{keyword}})[[:alpha:]_][[:alnum:]_]*\b

# Directive comment key.
directive: \b[[:alpha:]_][[:alnum:]_]*\b
directive: \b[[:alpha:]_-][[:alnum:]_-]*\b

# Single line only
inline_comment: /[*](?:[^*]|[*](?!/))*[*]/
Expand Down Expand Up @@ -117,7 +117,7 @@ contexts:

# https://golang.org/ref/spec#Comments
match-comments:
# Go has magic comments in the form of:
# Go has magic comments in the form of:
#
# //go:some_directive arg0 arg1 ...
#
Expand All @@ -132,15 +132,15 @@ contexts:
# highlighting them as compiler pragmas could be misleading. We scope them
# as plain comments by default, and add some detailed meta scopes for
# enterprising users wishing to add more color.
- match: (//)([a-z]+)(:)({{directive}}.*)
- match: (//)([a-z]+)(:)({{directive}})[ ]?
captures:
1: punctuation.definition.comment.go
2: meta.keyword.annotation.go
3: meta.punctuation.accessor.colon.go
4: meta.variable.function.go
push:
- meta_scope: meta.annotation.go comment.line.go
- match: \S+
- match: .+
scope: meta.variable.parameter.go
# End the annotation scope at EOL, but stretch the comment scope
# indefinitely to the right.
Expand All @@ -154,22 +154,18 @@ contexts:
- match: (//)(line) ([a-zA-Z0-9. :]*(?::[0-9]+){1,2})$
captures:
1: punctuation.definition.comment.go
2: meta.keyword.annotation.go
3: meta.variable.function.go
2: meta.variable.function.go
3: meta.variable.parameter.go
push:
- meta_scope: meta.annotation.go comment.line.go
- match: \S+
scope: meta.variable.parameter.go
# End the annotation scope at EOL, but stretch the comment scope
# indefinitely to the right.
- match: $
set: pop-line-comment

- match: (/\*)(line) ([a-zA-Z0-9. :]*(?::[0-9]+){1,2})(\*/)
captures:
1: punctuation.definition.comment.go
2: meta.keyword.annotation.go
3: meta.variable.function.go
2: meta.variable.function.go
3: meta.variable.parameter.go
4: punctuation.definition.comment.go
push:
- meta_scope: meta.annotation.go comment.block.go
Expand All @@ -184,14 +180,10 @@ contexts:
- match: (//)(export|extern) ({{ident}})$
captures:
1: punctuation.definition.comment.go
2: meta.keyword.annotation.go
3: meta.variable.function.go
2: meta.variable.function.go
3: meta.variable.parameter.go
push:
- meta_scope: meta.annotation.go comment.line.go
- match: \S+
scope: meta.variable.parameter.go
# End the annotation scope at EOL, but stretch the comment scope
# indefinitely to the right.
- match: $
set: pop-line-comment

Expand Down
21 changes: 21 additions & 0 deletions Go/syntax_test_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,51 +67,72 @@ You may have to disable Go-specific linters when working on this file.
// ^ -comment -meta -punctuation
// ^^ punctuation.definition.comment.go
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.go comment.line.go
// ^^ meta.keyword.annotation.go
// ^^^^^^^^ meta.variable.function.go
// ^^^^^^^^^^^^^ meta.variable.parameter.go
// ^ comment.line.go -meta.annotation

//lint:ignore U1000 Reason.
// ^ -comment -meta -punctuation
// ^^ punctuation.definition.comment.go
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.go comment.line.go
// ^^^^ meta.keyword.annotation.go
// ^^^^^^ meta.variable.function.go
// ^^^^^^^^^^^^^ meta.variable.parameter.go
// ^ comment.line.go -meta.annotation

//lint:file-ignore Reason.
// ^ -comment -meta -punctuation
// ^^ punctuation.definition.comment.go
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.go comment.line.go
// ^^^^ meta.keyword.annotation.go
// ^^^^^^^^^^^ meta.variable.function.go
// ^^^^^^^ meta.variable.parameter.go
// ^ comment.line.go -meta.annotation

//line :10
// ^ -comment -meta -punctuation
// ^^ punctuation.definition.comment.go
// ^^^^^^^^^^ meta.annotation.go comment.line.go
// ^^^^ meta.variable.function.go
// ^^^ meta.variable.parameter.go
// ^ comment.line.go -meta.annotation

//line file.rl:10
// ^ -comment -meta -punctuation
// ^^ punctuation.definition.comment.go
// ^^^^^^^^^^^^^^^^^ meta.annotation.go comment.line.go
// ^^^^ meta.variable.function.go
// ^^^^^^^^^^ meta.variable.parameter.go
// ^ comment.line.go -meta.annotation

//line file.rl:100:10
// ^ -comment -meta -punctuation
// ^^ punctuation.definition.comment.go
// ^^^^^^^^^^^^^^^^^^^^^ meta.annotation.go comment.line.go
// ^^^^ meta.variable.function.go
// ^^^^^^^^^^^^^^ meta.variable.parameter.go
// ^ comment.line.go -meta.annotation

/*line :10*/
// ^ -comment
// ^^^^^^^^^^^^ meta.annotation.go comment.block.go
// ^^^^ meta.variable.function.go
// ^^^ meta.variable.parameter.go
// ^ -comment.block.go -meta.annotation

/*line file.rl:10*/
// ^ -comment
// ^^^^^^^^^^^^^^^^^^^ meta.annotation.go comment.block.go
// ^^^^ meta.variable.function.go
// ^^^^^^^^^^ meta.variable.parameter.go
// ^ -comment.block.go -meta.annotation

/*line file.rl:100:10*/
// ^ -comment
// ^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.go comment.block.go
// ^^^^ meta.variable.function.go
// ^^^^^^^^^^^^^^ meta.variable.parameter.go
// ^ -comment.block.go -meta.annotation

/*line :10 */
Expand Down

0 comments on commit f58bc37

Please sign in to comment.