Skip to content

Commit

Permalink
[Go] syntax rework (#1662)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitranim authored and wbond committed Nov 29, 2018
1 parent c1a7427 commit 14a35f6
Show file tree
Hide file tree
Showing 30 changed files with 3,902 additions and 1,035 deletions.
39 changes: 0 additions & 39 deletions Go/Comments.tmPreferences

This file was deleted.

48 changes: 48 additions & 0 deletions Go/Default.sublime-keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[
// Auto-pair backquotes. Partially copied from the default Sublime keymap,
// with some modifications.
{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`$0`"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "source.go", },
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "(?:^|\\s)$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\\s|$)", "match_all": true },
]
},
{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`${0:$SELECTION}`"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "source.go", },
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true },
]
},
{ "keys": ["`"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "source.go", },
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true },
]
},
{ "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "source.go", },
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "`$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true },
]
},

// Insert an indented line when pressing Enter between parentheses.
{ "keys": ["enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "source.go", },
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\($", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true },
]
},
]
71 changes: 71 additions & 0 deletions Go/Go.sublime-completions
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"scope": "source.go",

"completions": [
// https://golang.org/ref/spec#Keywords
"break",
"default",
"func",
"interface",
"select",
"case",
"defer",
"go",
"map",
"struct",
"chan",
"else",
"goto",
"package",
"switch",
"const",
"fallthrough",
"if",
"range",
"type",
"continue",
"for",
"import",
"return",
"var",

// https://golang.org/ref/spec#Predeclared_identifiers
"bool",
"byte",
"complex64",
"complex128",
"error",
"float32",
"float64",
"int",
"int8",
"int16",
"int32",
"int64",
"rune",
"string",
"uint",
"uint8",
"uint16",
"uint32",
"uint64",
"uintptr",
"true",
"false",
"iota",
"nil",
"append",
"cap",
"close",
"complex",
"copy",
"delete",
"imag",
"len",
"make",
"new",
"panic",
"real",
"recover",
],
}
4 changes: 4 additions & 0 deletions Go/Go.sublime-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// Prefer tabs because gofmt enforces tabs.
"translate_tabs_to_spaces": false,
}
Loading

0 comments on commit 14a35f6

Please sign in to comment.