add grammar, syntax highlighting for go.mod and go.sum(#2344)

* add go.mod and go.sum support

* rename to Checksum
This commit is contained in:
Caleb Doxsey 2019-03-02 13:56:44 -07:00 коммит произвёл Ramya Rao
Родитель e19013abe8
Коммит df3499d1db
3 изменённых файлов: 237 добавлений и 0 удалений

Просмотреть файл

@ -72,6 +72,36 @@
"aliases": [
"Go"
]
},
{
"id": "go.mod",
"extensions": [
"go.mod"
],
"aliases": [
"Go Module File"
]
},
{
"id": "go.sum",
"extensions": [
"go.sum"
],
"aliases": [
"Go Checksum File"
]
}
],
"grammars": [
{
"language": "go.mod",
"scopeName": "go.mod",
"path": "./syntaxes/go.mod.tmGrammar.json"
},
{
"language": "go.sum",
"scopeName": "go.sum",
"path": "./syntaxes/go.sum.tmGrammar.json"
}
],
"snippets": [

Просмотреть файл

@ -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"
}
]
}
}
}

Просмотреть файл

@ -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"
}
}
}