diff --git a/Comments.tmPreferences b/Comments.tmPreferences new file mode 100644 index 00000000..68a68344 --- /dev/null +++ b/Comments.tmPreferences @@ -0,0 +1,39 @@ + + + + name + Comments + scope + source.go + settings + + shellVariables + + + name + TM_COMMENT_START + value + // + + + name + TM_COMMENT_START_2 + value + /* + + + name + TM_COMMENT_END_2 + value + */ + + + name + TM_COMMENT_DISABLE_INDENT_2 + value + yes + + + + + diff --git a/Indentation Rules.tmPreferences b/Indentation Rules.tmPreferences new file mode 100644 index 00000000..edf60670 --- /dev/null +++ b/Indentation Rules.tmPreferences @@ -0,0 +1,54 @@ + + + + name + Indentation Rules + scope + source.go + settings + + decreaseIndentPattern + + increaseIndentPattern + (?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) + $ + + + unIndentedLinePattern + ^\s*((/\*|\*/|//|import\b.*|package\b.*).*)?$ + + + diff --git a/something_borrowed/Go/generate.go b/something_borrowed/Go/generate.go index 76a8bd64..47a906b6 100644 --- a/something_borrowed/Go/generate.go +++ b/something_borrowed/Go/generate.go @@ -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")