Skip to content
Permalink
Browse files
fix broken commenting when the Go package is disabled
close #797
  • Loading branch information
DisposaBoy committed Dec 8, 2017
1 parent 1fd23d5 commit 749ac2285f6873dd78c8d1a355f02c7d3ed7b3db
Showing with 128 additions and 14 deletions.
  1. +39 −0 Comments.tmPreferences
  2. +54 −0 Indentation Rules.tmPreferences
  3. +35 −14 something_borrowed/Go/generate.go
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>source.go</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string>// </string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_START_2</string>
<key>value</key>
<string>/*</string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_END_2</string>
<key>value</key>
<string>*/</string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_DISABLE_INDENT_2</string>
<key>value</key>
<string>yes</string>
</dict>
</array>
</dict>
</dict>
</plist>
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Indentation Rules</string>
<key>scope</key>
<string>source.go</string>
<key>settings</key>
<dict>
<key>decreaseIndentPattern</key>
<string><![CDATA[(?x)
^ # start of line
(.*\*/)? # skip comments if present
( # three possibilities
\s* \} # whitespace and a closing curly brace
( # capture:
[^}{"']* \{ # anything other than curly braces or quotes, then open curly
)? # (optional)
[;\s]*? # any whitespace or semicolons
|
(?:\s* (case|default).*:) # case statements pop back one indent
|
(?: \) (?<! \( ) ) # closing braces not preceded by opening braces
)
(//.*|/\*.*\*/\s*)? # skip any comments (optional)
$ # end of line
]]></string>
<key>increaseIndentPattern</key>
<string>(?x)
^
(?: .* \*/ )? # skip any comments
(?:
(.* \{ [^}"'\n]*) # lines containing an open curly but no quotes or close curly
| # OR
(?:\s* (case|default).*:) # case statements
| # OR
(.* \( [^)"'\n]*) # lines containing an open brace but no quotes or close brace
)
(//.*|/\*.*\*/\s*)? # skip any comments (optional)
$
</string>
<!--
<key>indentNextLinePattern</key>
<string>(?x)^
(?! .* [;:{}] # do not indent when line ends with ;, :, {, or }
\s* (//|/[*] .* [*]/ \s* $) # …account for potential trailing comment
)
</string>
-->
<key>unIndentedLinePattern</key>
<string>^\s*((/\*|\*/|//|import\b.*|package\b.*).*)?$</string>
</dict>
</dict>
</plist>
@@ -11,28 +11,47 @@ import (
"net/http"
"os"
"os/exec"
"path/filepath"
)

type dlFile struct {
name string
url string
dirs []string
}

func main() {
urls := map[string]string{
"Comments.tmPreferences": "https://raw.githubusercontent.com/sublimehq/Packages/master/Go/Comments.tmPreferences",
"Indentation Rules.tmPreferences": "https://raw.githubusercontent.com/sublimehq/Packages/master/Go/Indentation%20Rules.tmPreferences",
"Go.sublime-syntax": "https://raw.githubusercontent.com/sublimehq/Packages/master/Go/Go.sublime-syntax",
urls := []dlFile{
{
name: "Comments.tmPreferences",
url: "https://raw.githubusercontent.com/sublimehq/Packages/master/Go/Comments.tmPreferences",
dirs: []string{"../..", "."},
},
{
name: "Indentation Rules.tmPreferences",
url: "https://raw.githubusercontent.com/sublimehq/Packages/master/Go/Indentation%20Rules.tmPreferences",
dirs: []string{"../..", "."},
},
{
name: "Go.sublime-syntax",
url: "https://raw.githubusercontent.com/sublimehq/Packages/master/Go/Go.sublime-syntax",
dirs: []string{"."},
},
}
for name, url := range urls {
dl(name, url)
for _, f := range urls {
dl(f)
}

cmd := exec.Command("git", "status", ".")
cmd := exec.Command("git", "status", "--short")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
}

func dl(name, url string) {
fmt.Printf("Sync %s: ", name)
func dl(f dlFile) {
fmt.Printf("Sync %s: ", f.name)

resp, err := http.Get(url)
resp, err := http.Get(f.url)
if err != nil {
fmt.Println(err)
return
@@ -45,10 +64,12 @@ func dl(name, url string) {
return
}

ioutil.WriteFile(name, content, 0644)
if err != nil {
fmt.Println(err)
return
for _, dir := range f.dirs {
ioutil.WriteFile(filepath.Join(dir, f.name), content, 0644)
if err != nil {
fmt.Println(err)
return
}
}

fmt.Println("ok")

0 comments on commit 749ac22

Please sign in to comment.