Skip to content

Commit

Permalink
[Go] preliminary support for Go 1.18 (#3289)
Browse files Browse the repository at this point in the history
* [Go] improve comments

* Convert anon to named contexts for compatibility with overrides.
* Avoid false positives when scoping javadoc bullets.
* Use `prototype` to reduce repetition.

* [Go] preliminary support for Go 1.18

Features:

  * [x] Support for ~.
  * [x] Support for `any` and `comparable`.
  * [x] Support for type unions.
  * [x] Support for general interfaces (with type unions).
  * [x] Support for type parameters in generic functions.
  * [x] Support for type parameters in method receivers of generic types.
  * [x] Support for type arguments following type names.
  * [x] Support for type parameters in type declarations.
  * [x] Support for embedded parametrized types in struct definitions.
  * [x] Support for type arguments between function name and function arguments.
  * [x] Support for `invalid.illegal` for dangling `)]}`.
  * [x] Slightly better meta scopes in type definitions.

Known regressions:

  * Embedded interfaces are no longer scoped as "inherited class", due
    to ambiguities.
  * "Namespace" idents such as `ident.` no longer support a comment
    between identifier and dot.
  * Last ident in parens followed by opening paren is no longer scoped
    as a function call, due to false positives and ambiguities.

Known issues and limitations:

  * Detection of type parameter lists and type argument lists is
    incomplete. In some places it relies on regex lookahead, which
    doesn't work across multiple lines. There are also edge case
    ambiguities which are supported by the Go compiler but not by
    our syntax.

* [Go] use `comment.line.double-slash` convention

* [Go] use `string.quoted.backtick` convention

* [Go] more consistent line terminators

* [Go] support folding of block comments

Co-authored-by: deathaxe <deathaxe@web.de>
  • Loading branch information
mitranim and deathaxe authored Oct 21, 2022
1 parent 3942b77 commit fe6ccee
Show file tree
Hide file tree
Showing 4 changed files with 3,032 additions and 667 deletions.
34 changes: 20 additions & 14 deletions Go/Fold.tmPreferences
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>scope</key>
<string>source.go</string>
<key>settings</key>
<dict>
<key>foldScopes</key>
<array>
<dict>
<key>begin</key>
<string>punctuation.section.braces.begin</string>
<key>end</key>
<string>punctuation.section.braces.end</string>
</dict>
</array>
</dict>
<key>scope</key>
<string>source.go</string>
<key>settings</key>
<dict>
<key>foldScopes</key>
<array>
<dict>
<key>begin</key>
<string>punctuation.section.braces.begin</string>
<key>end</key>
<string>punctuation.section.braces.end</string>
</dict>
<dict>
<key>begin</key>
<string>punctuation.definition.comment.begin.go</string>
<key>end</key>
<string>punctuation.definition.comment.end.go</string>
</dict>
</array>
</dict>
</dict>
</plist>
12 changes: 11 additions & 1 deletion Go/Go.sublime-completions
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"scope": "source.go",
"completions": [
// https://golang.org/ref/spec#Keywords
{
"trigger": "any",
"contents": "any",
"kind": "type"
},
{
"trigger": "append",
"contents": "append",
Expand Down Expand Up @@ -42,6 +47,11 @@
"contents": "close",
"kind": "function"
},
{
"trigger": "comparable",
"contents": "comparable",
"kind": "type"
},
{
"trigger": "complex",
"contents": "complex",
Expand Down Expand Up @@ -195,7 +205,7 @@
{
"trigger": "make",
"annotation": "make(type, 0)",
"contents": "make(${1:type}, 0)",
"contents": "make(${0:type}, 0)",
"kind": "snippet"
},
{
Expand Down
Loading

0 comments on commit fe6ccee

Please sign in to comment.