This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add grammar, syntax highlighting for go.mod and go.sum(#2344)
* add go.mod and go.sum support * rename to Checksum
- Loading branch information
1 parent
e19013a
commit df3499d
Showing
3 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
{ | ||
"scopeName": "go.mod", | ||
"patterns": [ | ||
{ | ||
"include": "#comments" | ||
}, | ||
{ | ||
"include": "#directive" | ||
} | ||
], | ||
"repository": { | ||
"directive": { | ||
"patterns": [ | ||
{ | ||
"comment": "Multi-Line directive", | ||
"begin": "(\\w+)\\s+\\(", | ||
"beginCaptures": { | ||
"1": { | ||
"name": "keyword.go.mod" | ||
} | ||
}, | ||
"end": "\\)", | ||
"patterns": [ | ||
{ | ||
"include": "#arguments" | ||
} | ||
] | ||
}, | ||
{ | ||
"comment": "Single-Line directive", | ||
"match": "(\\w+)\\s+(.*)", | ||
"captures": { | ||
"1": { | ||
"name": "keyword.go.mod" | ||
}, | ||
"2": { | ||
"patterns": [ | ||
{ | ||
"include": "#arguments" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"arguments": { | ||
"patterns": [ | ||
{ | ||
"include": "#comments" | ||
}, | ||
{ | ||
"include": "#double_quoted_string" | ||
}, | ||
{ | ||
"include": "#raw_quoted_string" | ||
}, | ||
{ | ||
"include": "#operator" | ||
}, | ||
{ | ||
"include": "#semver" | ||
}, | ||
{ | ||
"include": "#unquoted_string" | ||
} | ||
] | ||
}, | ||
"comments": { | ||
"patterns": [ | ||
{ | ||
"begin": "//", | ||
"beginCaptures": { | ||
"0": { | ||
"name": "punctuation.definition.comment.go.mod" | ||
} | ||
}, | ||
"end": "$", | ||
"name": "comment.line.double-slash.go.mod" | ||
} | ||
] | ||
}, | ||
"operator": { | ||
"match": "(=>)", | ||
"name": "operator.go.mod" | ||
}, | ||
"unquoted_string": { | ||
"comment": "Unquoted string", | ||
"match": "[^\\s]+", | ||
"name": "string.unquoted.go.mod" | ||
}, | ||
"double_quoted_string": { | ||
"comment": "Interpreted string literals", | ||
"begin": "\"", | ||
"beginCaptures": { | ||
"0": { | ||
"name": "punctuation.definition.string.begin.go.mod" | ||
} | ||
}, | ||
"end": "\"", | ||
"endCaptures": { | ||
"0": { | ||
"name": "punctuation.definition.string.end.go.mod" | ||
} | ||
}, | ||
"name": "string.quoted.double", | ||
"patterns": [ | ||
{ | ||
"include": "#string_escaped_char" | ||
}, | ||
{ | ||
"include": "#string_placeholder" | ||
} | ||
] | ||
}, | ||
"raw_quoted_string": { | ||
"comment": "Raw string literals", | ||
"begin": "`", | ||
"beginCaptures": { | ||
"0": { | ||
"name": "punctuation.definition.string.begin.go.mod" | ||
} | ||
}, | ||
"end": "`", | ||
"endCaptures": { | ||
"0": { | ||
"name": "punctuation.definition.string.end.go.mod" | ||
} | ||
}, | ||
"name": "string.quoted.raw", | ||
"patterns": [ | ||
{ | ||
"include": "#string_placeholder" | ||
} | ||
] | ||
}, | ||
"semver": { | ||
"comment": "Semver version strings (v1.2.3)", | ||
"match": "v(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[\\da-z-]+(?:\\.[\\da-z-]+)*)?(?:\\+[\\da-z-]+(?:\\.[\\da-z-]+)*)?", | ||
"name": "constant.language.go.mod" | ||
}, | ||
"string_escaped_char": { | ||
"patterns": [ | ||
{ | ||
"match": "\\\\([0-7]{3}|[abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})", | ||
"name": "constant.character.escape.go.mod" | ||
}, | ||
{ | ||
"match": "\\\\[^0-7xuUabfnrtv\\'\"]", | ||
"name": "invalid.illegal.unknown-escape.go.mod" | ||
} | ||
] | ||
}, | ||
"string_placeholder": { | ||
"patterns": [ | ||
{ | ||
"match": "%(\\[\\d+\\])?([\\+#\\-0\\x20]{,2}((\\d+|\\*)?(\\.?(\\d+|\\*|(\\[\\d+\\])\\*?)?(\\[\\d+\\])?)?))?[vT%tbcdoqxXUbeEfFgGsp]", | ||
"name": "constant.other.placeholder.go.mod" | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"scopeName": "go.sum", | ||
"patterns": [ | ||
{ | ||
"include": "#checksum" | ||
}, | ||
{ | ||
"include": "#semver" | ||
}, | ||
{ | ||
"include": "#unquoted_string" | ||
} | ||
], | ||
"repository": { | ||
"checksum": { | ||
"comment": "Checksum", | ||
"match": "h1:([^\\s]+)=", | ||
"captures": { | ||
"1": { | ||
"patterns": [ | ||
{ | ||
"match": "[a-zA-Z\\d+\\/]{43}", | ||
"name": "string.unquoted.go.sum" | ||
}, | ||
{ | ||
"match": ".*", | ||
"name": "invalid.illegal.unknown-hash.go.sum" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"semver": { | ||
"comment": "Semver version strings (v1.2.3)", | ||
"match": "v(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[\\da-z-]+(?:\\.[\\da-z-]+)*)?(?:\\+[\\da-z-]+(?:\\.[\\da-z-]+)*)?", | ||
"name": "constant.language.go.sum" | ||
}, | ||
"unquoted_string": { | ||
"comment": "Unquoted string", | ||
"match": "[^\\s]+", | ||
"name": "string.unquoted.go.sum" | ||
} | ||
} | ||
} |