Skip to content

Commit

Permalink
[Go] misc tweaks from code review
Browse files Browse the repository at this point in the history
Co-authored-by: deathaxe <deathaxe@web.de>
  • Loading branch information
mitranim and deathaxe committed Mar 29, 2022
1 parent eb48d10 commit ee72628
Showing 1 changed file with 6 additions and 30 deletions.
36 changes: 6 additions & 30 deletions Go/Go.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ variables:

# Note: this matches ALL valid identifiers, including predeclared constants,
# functions and types.
ident: \b(?!{{keyword}})[[:alpha:]_][[:alnum:]_]*\b
ident: (?!{{keyword}}){{keyword_or_ident}}

keyword_or_ident: \b[[:alpha:]_][[:alnum:]_]*\b

Expand Down Expand Up @@ -348,25 +348,6 @@ contexts:
- match: '{{ident}}(?=(?:{{noise}}\))*{{noise}}\()'
scope: variable.function.go

# See notes on `match-call-or-type-conversion`.
pop-call-or-type-conversion:
- include: pop-identifier-blank
- match: \b(?:make|new)\b(?=(?:{{noise}}\))*{{noise}}\()
scope: variable.function.go support.function.builtin.go
set: pop-arguments-starting-with-type
- match: '{{predeclared_type}}(?=(?:{{noise}}\))*{{noise}}\()'
scope: variable.function.go support.type.builtin.go
pop: true
- match: '{{predeclared_func}}(?=(?:{{noise}}\))*{{noise}}\()'
scope: variable.function.go support.function.builtin.go
pop: true
- match: '{{ident}}(?=(?:{{noise}}\))*(?:{{noise}}{{type_argument_list}})?{{noise}}\()'
scope: variable.function.go
set: pop-type-argument-list
- match: '{{ident}}(?=(?:{{noise}}\))*{{noise}}\()'
scope: variable.function.go
pop: true

# Note: this currently doesn't work across multiple lines.
match-short-variable-declarations:
- match: (?={{ident}}(?:{{noise}},{{noise}}{{ident}})*{{noise}}:=)
Expand Down Expand Up @@ -471,8 +452,7 @@ contexts:

pop-type-assertion:
- include: pop-on-paren-end
- match: (?=\S)
push: pop-type
- include: match-type

match-parens:
- match: \(
Expand Down Expand Up @@ -989,8 +969,7 @@ contexts:
- include: pop-before-terminator
- match: (?=\()
set: pop-func-parameter-list
- match: (?=\S)
set: pop-type
- include: pop-type

# https://golang.org/ref/spec#Function_types
#
Expand Down Expand Up @@ -1063,8 +1042,7 @@ contexts:
- include: match-comma
- include: match-ellipsis
- include: match-keywords
- match: (?=\S)
push: pop-type
- include: match-type

# At the time of writing, this is the only part of Go that uses "untyped"
# syntax for parameters, similar to function definitions in dynamic languages
Expand Down Expand Up @@ -1173,7 +1151,7 @@ contexts:

match-type:
- match: (?=\S)
push: pop-type
push: [pop-after-type, pop-type-single]

pop-type:
- match: (?=\S)
Expand Down Expand Up @@ -1269,7 +1247,6 @@ contexts:
- include: pop-before-brace-end
- include: pop-before-terminator
- include: pop-type
- include: match-any

pop-interface:
- match: \binterface\b
Expand Down Expand Up @@ -1349,8 +1326,7 @@ contexts:
- match: =
scope: keyword.operator.assignment.go
set: pop-type
- match: (?=\S)
set: pop-type
- include: pop-type

pop-const-type-and-or-assignment:
- include: pop-before-terminator
Expand Down

0 comments on commit ee72628

Please sign in to comment.