Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Go] syntax rework #1662

Merged
merged 30 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
984f814
[Go] syntax rework
mitranim Jul 14, 2018
31abd0d
[Go] consistent tmPreferences indentation
mitranim Jul 16, 2018
6e733ba
[Go] added missing scope selectors to keymap
mitranim Jul 16, 2018
adffe48
[Go] minor cosmetics
mitranim Jul 16, 2018
2938d85
[Go] removed dot autocompletion trigger
mitranim Jul 17, 2018
8d63f72
[Go] merged symbol settings files where possible
mitranim Jul 17, 2018
e1007b3
[Go] cosmetics in symbol preferences
mitranim Jul 26, 2018
caa2fd4
[Go] removed spaces from block comments
mitranim Jul 26, 2018
ed3c3bd
[Go] meta scope for //go: annotations
mitranim Aug 24, 2018
50997bd
[Go] number corrections
mitranim Aug 24, 2018
980645e
[Go] detect embedded struct fields when tagged
mitranim Aug 24, 2018
9fa51d2
[Go] corrected comma-grouped var and const declarations
mitranim Aug 24, 2018
982dcbc
[Go] removed stale symbol file
mitranim Sep 7, 2018
0392749
[Go] consistent escape sequences in char and string literals
mitranim Sep 7, 2018
eb519b4
[Go] removed unnecessary (?) syntax name
mitranim Sep 7, 2018
06e203c
[Go] detect embedded type followed by line comment
mitranim Oct 22, 2018
23993dc
[Go] cosmetic tests and comments
mitranim Oct 22, 2018
2825db4
[Go] don't unindent block comment terminator
mitranim Oct 22, 2018
a06dd39
[Go] cosmetic cleanup in noise regexp
deathaxe Oct 29, 2018
a820b27
[Go] storage scope overhaul
mitranim Oct 31, 2018
a182359
[Go] comment and whitespace cosmetics
mitranim Oct 31, 2018
7f44c59
[Go] better comment scoping
mitranim Oct 31, 2018
8614e81
[Go] cosmetic renaming for consistency
mitranim Oct 31, 2018
7bb6f90
[Go] corrected comment EOL rule
mitranim Oct 31, 2018
8c7bf1b
[Go] whitespace cosmetics in tests
mitranim Nov 28, 2018
5dbd19d
[Go] special scope for blank variable
mitranim Nov 28, 2018
c40f286
[Go] "fori" snippet produces valid syntax
mitranim Nov 28, 2018
c19aaec
[Go] slightly improved indent rules
mitranim Nov 28, 2018
02634d3
[Go] misc changes in comments
mitranim Nov 28, 2018
a7f273d
[Go] storage.keyword -> storage.type.keyword
mitranim Nov 28, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't have a selector context specifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added the missing selector.

{ "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 },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also doesn't have a selector context specifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added the missing selector.

{ "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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding a description for these completions, i.e. keyword. See http://docs.sublimetext.info/en/latest/reference/completions.html.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm the docs don't mention any descriptions.

Apparently, some completions in the standard packages use tab-separated triggers: word\tdescription. Tried this; it looks cool in the completion list, but suppresses the normal buffer completions, which is exactly what you don't want, especially in a standard package. If we could add descriptions without messing things up, I'd love to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Played with generating sublime-snippet files for these completions. Snippets have descriptions and don't suppress normal buffer completions. They also don't appear when you just hit ^Space or equivalent to bring up the completion list. The downside is that they clog up the Command Palette.

Really the problem is that even one sublime-completion with a tab-separated description completely suppresses buffer completion. It's ridiculous and wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh, sounds like sublimehq/sublime_text#1061 is striking again. I thought tab triggers wouldn't affect it.

Or maybe it is actually a different issue, but that would be surprising.

"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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is certainly debatable, but I don't have insight on whether people write Go without gofmt.

}
Loading