├── .gitignore ├── Commands ├── Build.tmCommand ├── Complete.tmCommand ├── Def.tmCommand ├── Documentation.tmCommand ├── Fmt.tmCommand ├── Help.tmCommand ├── Imports.tmCommand ├── Install.tmCommand ├── Lint.tmCommand ├── MetaLinter.tmCommand ├── Open Package.tmCommand ├── Rename.tmCommand ├── Run.tmCommand ├── Test.tmCommand └── Vet.tmCommand ├── LICENSE ├── Preferences ├── Comments.tmPreferences ├── Folding.tmPreferences ├── HTML (Go).tmPreferences ├── Indentation Rules.tmPreferences ├── Symbol List: Functions.tmPreferences └── Symbol List: Methods.tmPreferences ├── README.md ├── Snippets ├── Case Clause.tmSnippet ├── Channel.tmSnippet ├── Constant.tmSnippet ├── Constants.tmSnippet ├── Default Clause.tmSnippet ├── Deferred Call.tmSnippet ├── Empty Interface.tmSnippet ├── For Index Loop.tmSnippet ├── For Loop.tmSnippet ├── For Range Loop.tmSnippet ├── Fprintf.tmSnippet ├── Function Type.tmSnippet ├── Function w: result vars.tmSnippet ├── Function.tmSnippet ├── Goroutine Call.tmSnippet ├── If Statement.tmSnippet ├── If err.tmSnippet ├── Import.tmSnippet ├── Imports.tmSnippet ├── Init Function.tmSnippet ├── Initialize.tmSnippet ├── Interface.tmSnippet ├── Main Function.tmSnippet ├── Make.tmSnippet ├── Map.tmSnippet ├── Method w: result vars.tmSnippet ├── Method.tmSnippet ├── New.tmSnippet ├── Package.tmSnippet ├── Pair.tmSnippet ├── Print.tmSnippet ├── Printf.tmSnippet ├── Return Statement.tmSnippet ├── Select Statement.tmSnippet ├── Send_Receive.tmSnippet ├── Slice.tmSnippet ├── Struct.tmSnippet ├── Switch Statement.tmSnippet ├── Test.tmSnippet ├── Type.tmSnippet ├── Types.tmSnippet ├── Variable.tmSnippet ├── Variables.tmSnippet ├── fmt_Println.tmSnippet └── iota.tmSnippet ├── Support ├── HELP.md ├── go_setup.sh ├── gomate.rb └── icons │ ├── const.pdf │ ├── func.pdf │ ├── icons.svg │ ├── package.pdf │ ├── type.pdf │ └── var.pdf ├── Syntaxes ├── Go.tmLanguage ├── HTML (Go).tmLanguage └── bugs.go └── info.plist /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /Commands/Build.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | autoScrollOutput 6 | 7 | beforeRunningCommand 8 | saveModifiedFiles 9 | command 10 | #!/usr/bin/env ruby 11 | 12 | require "#{ENV['TM_BUNDLE_SUPPORT']}/gomate" 13 | Go::go "build", :verb => "Building" 14 | input 15 | document 16 | inputFormat 17 | text 18 | keyEquivalent 19 | @b 20 | name 21 | Build 22 | outputCaret 23 | afterOutput 24 | outputFormat 25 | html 26 | outputLocation 27 | newWindow 28 | requiredCommands 29 | 30 | 31 | command 32 | go 33 | locations 34 | 35 | /opt/local/bin/go 36 | /usr/local/bin/go 37 | /usr/local/go/bin/go 38 | 39 | variable 40 | TM_GO 41 | 42 | 43 | scope 44 | source.go 45 | uuid 46 | 73628139-0077-4F09-9B72-77546D7C2D2D 47 | version 48 | 2 49 | 50 | 51 | -------------------------------------------------------------------------------- /Commands/Complete.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby18 9 | 10 | require "open3" 11 | 12 | require ENV['TM_SUPPORT_PATH'] + "/lib/ui.rb" 13 | require ENV['TM_SUPPORT_PATH'] + "/lib/escape.rb" 14 | require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes.rb" 15 | require ENV['TM_SUPPORT_PATH'] + "/lib/web_preview" 16 | require ENV['TM_SUPPORT_PATH'] + "/lib/tm/htmloutput.rb" 17 | 18 | # TextMate's special GOPATH used in .tm_properties files prepended to the environment's GOPATH 19 | ENV['GOPATH'] = (ENV.has_key?('TM_GOPATH') ? ENV['TM_GOPATH'] : '') + 20 | (ENV.has_key?('GOPATH') ? ':' + ENV['GOPATH'] : '').sub(/^:+/,'') 21 | 22 | # Call tool to determine gopath 23 | if ENV.has_key?('TM_GO_DYNAMIC_GOPATH') 24 | Dir.chdir(ENV['TM_DIRECTORY']) do 25 | ENV['GOPATH'] = `#{ENV['TM_GO_DYNAMIC_GOPATH']}`.chomp 26 | end 27 | end 28 | 29 | gocode = ENV['TM_GOCODE'] || 'gocode' 30 | 31 | # load current document from stdin 32 | document = [] 33 | while line = $stdin.gets 34 | document.push(line) 35 | end 36 | 37 | # byte offset of cursor position from the beginning of file 38 | cursor = document[ 0, ENV['TM_LINE_NUMBER'].to_i - 1].join().length + ENV['TM_LINE_INDEX'].to_i 39 | 40 | # send document to stdin of gocode and read output 41 | output = "" 42 | Open3.popen3("#{gocode} -f=csv autocomplete #{ENV['TM_FILEPATH']} #{cursor}") {|stdin, stdout, stderr| 43 | stdin.puts document.join 44 | stdin.close 45 | output = stdout.readlines.join 46 | } 47 | 48 | # quit if no completions found 49 | TextMate.exit_show_tool_tip("No completions found.") if output.length == 0 50 | 51 | # set up images for use by DIALOG 52 | # this probably should be done only once, somehow. 53 | icon_plist = "{ " + [ "const", "func", "package", "type", "var" ].map { |v| 54 | "#{v} = '#{ENV['TM_BUNDLE_SUPPORT']}/icons/#{v}.pdf';" 55 | }.join(" ") + " }" 56 | system( ENV['DIALOG'], "images", "--register", icon_plist ) 57 | 58 | # helper function to build the choice hash 59 | def make_completion_hash(line) 60 | comp = line.split(",,", 3) 61 | 62 | match = comp[1] 63 | image = comp[0] 64 | 65 | display = " " + comp[1] 66 | display += comp[0] == "func" ? comp[2].gsub(/^func/, "") : " " + comp[2] 67 | 68 | # input : "foo(x func(func())) (z int, k int)" 69 | # output: "0000111111122222210001111111111110" 70 | def depth_at_i(sig) 71 | depths = Array.new 72 | depth = 0 73 | sig.chars { |ch| 74 | depth-=1 if ch == ")" 75 | depths << depth 76 | depth+=1 if ch == "(" 77 | } 78 | return depths 79 | end 80 | 81 | # returns function arguments in the form "x arg, y arg" 82 | def get_f_args(sig) 83 | depths = depth_at_i(sig) 84 | pos = sig.index(")") 85 | while pos != nil && depths[pos] > 0 86 | pos = sig.index(")", pos+1) 87 | end 88 | return sig[ Range.new(sig.index("(")+1, pos - 1) ] 89 | end 90 | 91 | def split_args(sig) 92 | args = Array.new 93 | depths = depth_at_i(sig) 94 | start = 0 95 | pos = sig.index(",") 96 | 97 | while pos != nil 98 | if depths[pos] == 0 99 | args << sig[ Range.new(start, pos-1) ] 100 | start = pos+1 101 | end 102 | pos = sig.index(",", pos+1) 103 | end 104 | 105 | lastarg = sig[ Range.new(start, sig.length) ].strip 106 | args << lastarg unless lastarg == "" 107 | return args 108 | end 109 | 110 | if comp[0] == "func" 111 | i = 0 112 | insert = "(" + split_args( get_f_args( display )).map { |m| "${#{i += 1}:"+e_snp(m)+"}" }.join(", ") + ")$0" 113 | else 114 | insert = "" 115 | end 116 | 117 | return { 'match' => match, 'display' => display, 'insert' => insert, 'image' => image } 118 | end 119 | 120 | # build the list of completion choices. 121 | hash = output.split("\n").collect { |v| make_completion_hash( v ) } 122 | options = { :extra_chars => "_", :case_insensitive => false } 123 | 124 | # if there is only one match, insert. no need to show the menu 125 | if hash.length == 1 126 | word = ENV['TM_CURRENT_WORD'] || "" 127 | snippet = hash[0]["match"].gsub(/^#{Regexp.escape(word)}/, "") + hash[0]["insert"] 128 | #`"$DIALOG" x-insert --snippet #{e_sh snippet}` 129 | #full = document.join() 130 | #print e_sn(full[0..cursor]) + "$0" + e_sn(full[cursor+1..-1]) 131 | TextMate.exit_insert_snippet( snippet ) 132 | else 133 | TextMate::UI.complete( hash , options ) 134 | end 135 | fallbackInput 136 | word 137 | hideFromUser 138 | true 139 | input 140 | document 141 | inputFormat 142 | text 143 | keyEquivalent 144 | ~ 145 | name 146 | Complete 147 | outputCaret 148 | afterOutput 149 | outputFormat 150 | text 151 | outputLocation 152 | atCaret 153 | requiredCommands 154 | 155 | 156 | command 157 | gocode 158 | moreInfoURL 159 | https://github.com/nsf/gocode 160 | variable 161 | TM_GOCODE 162 | 163 | 164 | scope 165 | source.go 166 | uuid 167 | FE908865-7729-4926-9FAC-2D54895BEA48 168 | version 169 | 2 170 | 171 | 172 | -------------------------------------------------------------------------------- /Commands/Def.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby18 9 | 10 | require ENV['TM_SUPPORT_PATH'] + '/lib/textmate' 11 | require ENV['TM_SUPPORT_PATH'] + '/lib/tm/process' 12 | require ENV['TM_SUPPORT_PATH'] + '/lib/tm/save_current_document' 13 | require 'pathname' 14 | 15 | # TextMate's special TM_GODEF or expect 'godef' on PATH 16 | godef_cmd = ENV['TM_GODEF'] || 'godef' 17 | 18 | TextMate.save_if_untitled('go') 19 | 20 | # load current document from stdin 21 | document = [] 22 | while line = $stdin.gets 23 | document.push(line) 24 | end 25 | 26 | # byte offset of cursor position from the beginning of file 27 | cursor = document[ 0, ENV['TM_LINE_NUMBER'].to_i - 1].join().length + ENV['TM_LINE_INDEX'].to_i 28 | 29 | args = [] 30 | args.push(godef_cmd) 31 | args.push('-f') 32 | args.push(ENV['TM_FILEPATH']) 33 | args.push('-o') 34 | args.push("#{cursor}") 35 | 36 | # /usr/local/Cellar/go/1.7.1/libexec/src/database/sql/sql.go:960:15 37 | out, err = TextMate::Process.run(*args) 38 | 39 | if err.nil? || err == '' 40 | file_details = out.split(':') 41 | file = Pathname.new(file_details[0]).realpath 42 | TextMate.go_to(:file => file, 43 | :line => file_details[1].to_i, 44 | :column => file_details[2].to_i) 45 | elsif err.casecmp "godef: no identifier found"; 46 | require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb" 47 | package = TextMate::UI.request_string :title => "Open Package", :default => '', :prompt => "Which package do you wish to open?" 48 | #TODO: Find and open package 49 | else 50 | TextMate.exit_show_tool_tip(err) 51 | end 52 | input 53 | selection 54 | inputFormat 55 | text 56 | keyEquivalent 57 | ^. 58 | name 59 | Go to Definition 60 | outputCaret 61 | afterOutput 62 | outputFormat 63 | text 64 | outputLocation 65 | toolTip 66 | requiredCommands 67 | 68 | 69 | command 70 | godef 71 | moreInfoURL 72 | https://github.com/rogpeppe/godef 73 | variable 74 | TM_GODEF 75 | 76 | 77 | scope 78 | source.go 79 | uuid 80 | A04DD936-EEB1-484E-BF47-98BD6709D00C 81 | version 82 | 2 83 | 84 | 85 | -------------------------------------------------------------------------------- /Commands/Documentation.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | saveModifiedFiles 7 | command 8 | #!/usr/bin/env ruby 9 | 10 | require "#{ENV['TM_BUNDLE_SUPPORT']}/gomate" 11 | Go::gogetdoc 12 | 13 | fallbackInput 14 | word 15 | input 16 | document 17 | inputFormat 18 | text 19 | keyEquivalent 20 | ^h 21 | name 22 | Show Documentation 23 | outputCaret 24 | afterOutput 25 | outputFormat 26 | text 27 | outputLocation 28 | toolTip 29 | requiredCommands 30 | 31 | 32 | command 33 | gogetdoc 34 | locations 35 | 36 | /opt/local/bin/gogetdoc 37 | /usr/local/bin/gogetdoc 38 | /usr/local/go/bin/gogetdoc 39 | 40 | variable 41 | TM_GOGETDOC 42 | 43 | 44 | scope 45 | source.go 46 | uuid 47 | 7BCFCFC8-9152-4638-8436-E17B0C754C8D 48 | version 49 | 2 50 | 51 | 52 | -------------------------------------------------------------------------------- /Commands/Fmt.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env bash 9 | . "${TM_SUPPORT_PATH}/lib/bash_init.sh" 10 | . "${TM_BUNDLE_SUPPORT}/go_setup.sh" 11 | 12 | (eval "${TM_GOFMT:-gofmt}") || exit_show_tool_tip 13 | input 14 | document 15 | inputFormat 16 | text 17 | keyEquivalent 18 | 19 | name 20 | Fmt 21 | outputCaret 22 | interpolateByLine 23 | outputFormat 24 | text 25 | outputLocation 26 | replaceDocument 27 | requiredCommands 28 | 29 | 30 | command 31 | gofmt 32 | locations 33 | 34 | /opt/local/bin/gofmt 35 | /usr/local/bin/gofmt 36 | /usr/local/go/bin/gofmt 37 | 38 | variable 39 | TM_GOFMT 40 | 41 | 42 | scope 43 | source.go 44 | semanticClass 45 | callback.document.will-save 46 | uuid 47 | B0271A46-F6EF-4D2F-95A6-EC067E69155C 48 | version 49 | 2 50 | 51 | 52 | -------------------------------------------------------------------------------- /Commands/Help.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/bin/bash 9 | [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh" 10 | 11 | . "$TM_SUPPORT_PATH/lib/webpreview.sh" 12 | html_header "Go Bundle Help" "Go" 13 | "$TM_SUPPORT_PATH/lib/markdown_to_help.rb" "$TM_BUNDLE_SUPPORT/HELP.md" 14 | html_footer 15 | exit_show_html 16 | input 17 | none 18 | inputFormat 19 | text 20 | name 21 | Help 22 | outputCaret 23 | afterOutput 24 | outputFormat 25 | html 26 | outputLocation 27 | newWindow 28 | scope 29 | source.go 30 | uuid 31 | 98F0F28C-3B03-4792-AF44-24E2C4327EED 32 | version 33 | 2 34 | 35 | 36 | -------------------------------------------------------------------------------- /Commands/Imports.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | saveModifiedFiles 7 | command 8 | #!/usr/bin/env bash 9 | . "${TM_SUPPORT_PATH}/lib/bash_init.sh" 10 | . "${TM_BUNDLE_SUPPORT}/go_setup.sh" 11 | 12 | (eval "${TM_GOIMPORTS:-goimports}") || exit_show_tool_tip 13 | input 14 | document 15 | inputFormat 16 | text 17 | keyEquivalent 18 | ^H 19 | name 20 | Imports 21 | outputCaret 22 | interpolateByLine 23 | outputFormat 24 | text 25 | outputLocation 26 | replaceDocument 27 | requiredCommands 28 | 29 | 30 | command 31 | goimports 32 | moreInfoURL 33 | https://golang.org/x/tools/cmd/goimports 34 | variable 35 | TM_GOIMPORTS 36 | 37 | 38 | scope 39 | source.go 40 | uuid 41 | 5509FB1E-C780-44ED-8BCF-4300ABC30C32 42 | version 43 | 2 44 | 45 | 46 | -------------------------------------------------------------------------------- /Commands/Install.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | autoScrollOutput 6 | 7 | beforeRunningCommand 8 | saveModifiedFiles 9 | command 10 | #!/usr/bin/env ruby 11 | 12 | require "#{ENV['TM_BUNDLE_SUPPORT']}/gomate" 13 | Go::go "install", :verb => "Installing" 14 | input 15 | document 16 | inputFormat 17 | text 18 | keyEquivalent 19 | @I 20 | name 21 | Install 22 | outputCaret 23 | afterOutput 24 | outputFormat 25 | html 26 | outputLocation 27 | newWindow 28 | requiredCommands 29 | 30 | 31 | command 32 | go 33 | locations 34 | 35 | /opt/local/bin/go 36 | /usr/local/bin/go 37 | /usr/local/go/bin/go 38 | 39 | variable 40 | TM_GO 41 | 42 | 43 | scope 44 | source.go 45 | uuid 46 | B455A84C-0F20-494A-A3CC-49A89434DAB4 47 | version 48 | 2 49 | 50 | 51 | -------------------------------------------------------------------------------- /Commands/Lint.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | saveActiveFile 7 | command 8 | #!/usr/bin/env ruby 9 | 10 | require "#{ENV['TM_BUNDLE_SUPPORT']}/gomate" 11 | Go::golint 12 | 13 | input 14 | none 15 | inputFormat 16 | text 17 | keyEquivalent 18 | ^L 19 | name 20 | Lint 21 | outputCaret 22 | interpolateByLine 23 | outputFormat 24 | html 25 | outputLocation 26 | newWindow 27 | requiredCommands 28 | 29 | 30 | command 31 | golint 32 | moreInfoURL 33 | https://github.com/golang/lint 34 | variable 35 | TM_GOLINT 36 | 37 | 38 | scope 39 | source.go 40 | uuid 41 | 7E52594B-80CA-4EDD-B2B8-C54EB3844E95 42 | version 43 | 2 44 | 45 | 46 | -------------------------------------------------------------------------------- /Commands/MetaLinter.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby 9 | 10 | require "#{ENV['TM_BUNDLE_SUPPORT']}/gomate" 11 | Go::gometalinter 12 | 13 | input 14 | none 15 | inputFormat 16 | text 17 | keyEquivalent 18 | ^M 19 | name 20 | MetaLinter 21 | outputCaret 22 | afterOutput 23 | outputFormat 24 | html 25 | outputLocation 26 | newWindow 27 | requiredCommands 28 | 29 | 30 | command 31 | gometalinter 32 | moreInfoURL 33 | https://github.com/alecthomas/gometalinter 34 | variable 35 | TM_GOMETALINTER 36 | 37 | 38 | scope 39 | source.go 40 | uuid 41 | B09B40EA-FF74-425E-BE7F-A892077CC1F8 42 | version 43 | 2 44 | 45 | 46 | -------------------------------------------------------------------------------- /Commands/Open Package.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby18 -wKU 9 | require "shellwords" 10 | require "#{ENV['TM_BUNDLE_SUPPORT']}/gomate" # import to get dynamic gopath if set 11 | 12 | def import_path 13 | if ENV.has_key? 'TM_SELECTED_TEXT' 14 | ENV['TM_SELECTED_TEXT'] 15 | elsif ENV['TM_CURRENT_LINE'] =~ /^\s*(?:import\s+)?(?:\.|[[:alpha:]_][[:alnum:]_]*\s+)?(["`])(.*?)\1/; 16 | $2 17 | else 18 | defaultText = %x{ /usr/bin/pbpaste -pboard find } 19 | require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb" 20 | TextMate::UI.request_string :title => "Open Package", :default => defaultText, :prompt => "Which package do you wish to open?" 21 | end 22 | end 23 | 24 | def go_path 25 | env = %x{"${TM_GO:-go}" env} 26 | if $? == 0 27 | lcal, root = [], [] 28 | env.scan(/^GO(PATH|ROOT)="(.*)"/) do |key,value| 29 | case key 30 | when 'PATH'; lcal = value.split(':').map { |dir| "#{dir}/src" } 31 | when 'ROOT'; root = value.split(':').map { |dir| "#{dir}/src" } 32 | end 33 | end 34 | [ lcal, root ].flatten 35 | else 36 | ENV['GOPATH'].to_s.split(':').map { |dir| "#{dir}/src" } 37 | end 38 | end 39 | 40 | def find_package_path(package) 41 | if ENV.has_key?('TM_GO_DYNAMIC_PKG_PATH') 42 | path = `#{ENV['TM_GO_DYNAMIC_PKG_PATH']} #{package}`.chomp 43 | return path if path != nil && !path.empty? 44 | end 45 | 46 | go_path.each do |dir| 47 | path = File.expand_path(package, dir) 48 | if File.directory?(path) 49 | files = Dir.entries(path).select { |file| file =~ /\.go$/ && file !~ /_test\.go$/ } 50 | return files.size == 1 ? File.join(path, files.first) : path 51 | end 52 | end 53 | nil 54 | end 55 | 56 | if package = import_path() 57 | if path = find_package_path(package) 58 | %x{"$TM_MATE" #{path.shellescape}} 59 | else 60 | require "#{ENV['TM_SUPPORT_PATH']}/lib/exit_codes.rb" 61 | TextMate.exit_show_tool_tip "Unable to locate package for import path ‘#{package}’." 62 | end 63 | end 64 | 65 | input 66 | selection 67 | inputFormat 68 | text 69 | keyEquivalent 70 | @D 71 | name 72 | Open Package 73 | outputCaret 74 | afterOutput 75 | outputFormat 76 | text 77 | outputLocation 78 | discard 79 | scope 80 | source.go 81 | uuid 82 | D3CD6B51-3A7E-4356-85F4-B76B8336BEF2 83 | version 84 | 2 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /Commands/Rename.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby18 9 | require ENV['TM_SUPPORT_PATH'] + '/lib/textmate' 10 | require ENV['TM_SUPPORT_PATH'] + '/lib/ui' 11 | require ENV['TM_SUPPORT_PATH'] + '/lib/tm/process' 12 | require ENV['TM_SUPPORT_PATH'] + '/lib/tm/save_current_document' 13 | 14 | # TextMate's special TM_GORENAME or expect 'gorename' on PATH 15 | gorename_cmd = ENV['TM_GORENAME'] || 'gorename' 16 | 17 | # Save file. gogetdoc only accepts guru's archive format, which we don't currently support 18 | TextMate.save_if_untitled('go') 19 | 20 | # load current document from stdin 21 | document = [] 22 | while line = $stdin.gets 23 | document.push(line) 24 | end 25 | 26 | # byte offset of cursor position from the beginning of file 27 | cursor = document[ 0, ENV['TM_LINE_NUMBER'].to_i - 1].join().length + ENV['TM_LINE_INDEX'].to_i 28 | 29 | # get final name from user 30 | to = TextMate::UI.request_string :title => "Rename Symbol", :default => '', :prompt => "What would you like to rename this to?" 31 | 32 | args = [] 33 | args.push(gorename_cmd) 34 | args.push('-v') 35 | args.push('-offset') 36 | args.push("#{ENV['TM_FILEPATH']}:##{cursor}") 37 | args.push('-to') 38 | args.push(to) 39 | 40 | out, err = TextMate::Process.run(*args) 41 | 42 | if err.nil? || err == '' 43 | TextMate.exit_create_new_document(out) 44 | else 45 | TextMate.exit_show_tool_tip(err) 46 | end 47 | input 48 | document 49 | inputFormat 50 | text 51 | keyEquivalent 52 | ^R 53 | name 54 | Rename 55 | outputCaret 56 | afterOutput 57 | outputFormat 58 | html 59 | outputLocation 60 | newWindow 61 | requiredCommands 62 | 63 | 64 | command 65 | gorename 66 | moreInfoURL 67 | https://golang.org/x/tools/cmd/gorename 68 | variable 69 | TM_GORENAME 70 | 71 | 72 | scope 73 | source.go 74 | uuid 75 | 0E76DBD3-03DD-4184-8EED-A3E4F790B88D 76 | version 77 | 2 78 | 79 | 80 | -------------------------------------------------------------------------------- /Commands/Run.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | autoScrollOutput 6 | 7 | beforeRunningCommand 8 | saveModifiedFiles 9 | command 10 | #!/usr/bin/env ruby 11 | 12 | require "#{ENV['TM_BUNDLE_SUPPORT']}/gomate" 13 | Go::go "run", :verb => "Running" 14 | 15 | input 16 | document 17 | inputFormat 18 | text 19 | keyEquivalent 20 | @r 21 | name 22 | Run 23 | outputCaret 24 | afterOutput 25 | outputFormat 26 | html 27 | outputLocation 28 | newWindow 29 | requiredCommands 30 | 31 | 32 | command 33 | go 34 | locations 35 | 36 | /opt/local/bin/go 37 | /usr/local/bin/go 38 | /usr/local/go/bin/go 39 | 40 | variable 41 | TM_GO 42 | 43 | 44 | scope 45 | source.go 46 | uuid 47 | 0B3C3EB0-9F51-4997-A87D-ECA507D8E31E 48 | version 49 | 2 50 | 51 | 52 | -------------------------------------------------------------------------------- /Commands/Test.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | autoScrollOutput 6 | 7 | beforeRunningCommand 8 | saveModifiedFiles 9 | command 10 | #!/usr/bin/env ruby 11 | 12 | require "#{ENV['TM_BUNDLE_SUPPORT']}/gomate" 13 | Go::go "test", :verb => "Testing" 14 | 15 | input 16 | document 17 | inputFormat 18 | text 19 | keyEquivalent 20 | @R 21 | name 22 | Test 23 | outputCaret 24 | afterOutput 25 | outputFormat 26 | html 27 | outputLocation 28 | newWindow 29 | requiredCommands 30 | 31 | 32 | command 33 | go 34 | locations 35 | 36 | /opt/local/bin/go 37 | /usr/local/bin/go 38 | /usr/local/go/bin/go 39 | 40 | variable 41 | TM_GO 42 | 43 | 44 | scope 45 | source.go 46 | uuid 47 | 0F6A8710-54FC-48F5-9D02-D093DA001D17 48 | version 49 | 2 50 | 51 | 52 | -------------------------------------------------------------------------------- /Commands/Vet.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby 9 | 10 | require "#{ENV['TM_BUNDLE_SUPPORT']}/gomate" 11 | Go::go "vet", :verb => "Vetting" 12 | 13 | input 14 | document 15 | inputFormat 16 | text 17 | keyEquivalent 18 | ^V 19 | name 20 | Vet 21 | outputCaret 22 | afterOutput 23 | outputFormat 24 | html 25 | outputLocation 26 | newWindow 27 | requiredCommands 28 | 29 | 30 | command 31 | go 32 | locations 33 | 34 | /opt/local/bin/go 35 | /usr/local/bin/go 36 | /usr/local/go/bin/go 37 | 38 | variable 39 | TM_GO 40 | 41 | 42 | scope 43 | source.go 44 | uuid 45 | 72CC95BA-C5CA-4D39-A7E6-9533B33B9979 46 | version 47 | 2 48 | 49 | 50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009, Jim Dovey 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | - Neither the name of the copyright holder nor the names of the software's contributors may be used to endorse or promote products derived from this software without specific prior written permission. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | 12 | Portions based on Allan Odgaard's C bundle for TextMate. -------------------------------------------------------------------------------- /Preferences/Comments.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Comments 7 | scope 8 | source.go 9 | settings 10 | 11 | shellVariables 12 | 13 | 14 | name 15 | TM_COMMENT_START 16 | value 17 | // 18 | 19 | 20 | name 21 | TM_COMMENT_START_2 22 | value 23 | /* 24 | 25 | 26 | name 27 | TM_COMMENT_END_2 28 | value 29 | */ 30 | 31 | 32 | name 33 | TM_COMMENT_DISABLE_INDENT_2 34 | value 35 | yes 36 | 37 | 38 | 39 | uuid 40 | 05400837-EE8F-44D1-A636-3EEB0E82FFF5 41 | 42 | 43 | -------------------------------------------------------------------------------- /Preferences/Folding.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Folding 7 | scope 8 | source.go 9 | settings 10 | 11 | foldingIndentedBlockStart 12 | ^\s*(case|default)\b 13 | foldingStartMarker 14 | (?x) 15 | /\*\*(?!\*) # opening C-style comment with 2 asterisks but no third later on 16 | | # OR 17 | ^ # start of line... 18 | (?! # ...which does NOT contain... 19 | [^{(]*?// # ...a possible bunch of non-opening-braces, followed by a C++ comment 20 | | # OR 21 | [^{(]*?/\*(?!.*?\*/.*?[{(]) # ...a possible bunch of non-opening-braces, followed by a C comment with no ending 22 | ) 23 | .*? # ...any characters (or none)... 24 | [{(]\s* # ...followed by an open brace and zero or more whitespace... 25 | ( # ...followed by... 26 | $ # ...the end of line... 27 | | # OR 28 | // # ...a C++ comment... 29 | | # OR 30 | /\*(?!.*?\*/.*\S) # ...a C comment, so long as no non-whitespace chars follow it.. 31 | ) 32 | 33 | foldingStopMarker 34 | (?<!\*)\*\*/|^\s*[})] 35 | 36 | uuid 37 | 21783905-48ED-47DD-9EBA-0DF5FDBA1F4E 38 | 39 | 40 | -------------------------------------------------------------------------------- /Preferences/HTML (Go).tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | HTML (Go) 7 | scope 8 | text.html.go 9 | settings 10 | 11 | decreaseIndentPattern 12 | (?x) 13 | ^\s* 14 | (</(?!html) 15 | [A-Za-z0-9]+\b[^>]*> 16 | |--> 17 | |^\s*{{\s*(?:else(?: if)?|end)\b.*?}}$ 18 | |\} 19 | ) 20 | foldingStartMarker 21 | (?x) 22 | (<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|li|form|dl|section|article|header|footer|nav|aside)\b.*?> 23 | |<!--(?!.*--\s*>) 24 | |^\s*{{\s*(?:if|else(?: if)?|range|with)\b.*?(?<!end)}}$ 25 | ) 26 | foldingStopMarker 27 | (?x) 28 | (</(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|li|form|dl|section|article|header|footer|nav|aside)> 29 | |^(?!.*?<!--).*?--\s*> 30 | |^\s*{{\s*(?:else(?: if)?|end)\b.*?}}$ 31 | ) 32 | increaseIndentPattern 33 | (?x) 34 | <(?!\?|(?:area|base|br|col|frame|hr|html|img|input|link|meta|param)\b|[^>]*/>) 35 | ([A-Za-z0-9]+)(?=\s|>)\b[^>]*>(?!.*</\1>) 36 | |<!--(?!.*-->) 37 | |^\s*{{\s*(?:if|else(?: if)?|range|with)\b.*?(?<!end)}}$ 38 | |\{[^}"']*$ 39 | 40 | 41 | uuid 42 | 4D9E08E8-FD1E-44AC-BF35-B4FB836F3367 43 | 44 | 45 | -------------------------------------------------------------------------------- /Preferences/Indentation Rules.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Indentation Rules 7 | scope 8 | source.go 9 | settings 10 | 11 | decreaseIndentPattern 12 | (?x)^ 13 | ( .* [*]/ )? 14 | ( \s* \} .* 15 | | \s* \) ( [^)("'\n]* \( )? [;,\s]* 16 | | ( \s* (case|default)\b .* ) 17 | ) 18 | ( \s* ( //.* | /[*] .*? [*]/ ) )* 19 | \s* $ 20 | increaseIndentPattern 21 | (?x)^ 22 | ( .* [*]/ )? 23 | ( ( .* \{ [^}"'\n]* ) 24 | | ( .* \( [^)"'\n]* ) 25 | | ( \s* (case|default)\b .* ) 26 | ) 27 | ( \s* ( //.* | /[*] .*? [*]/ ) )* 28 | \s* $ 29 | zeroIndentPattern 30 | ^(?!default:)\w+:.*$ 31 | 32 | uuid 33 | 160118A4-208D-4422-AFF0-0C21B5B78AAF 34 | 35 | 36 | -------------------------------------------------------------------------------- /Preferences/Symbol List: Functions.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Symbol List: Functions 7 | scope 8 | source.go meta.function.declaration.go 9 | settings 10 | 11 | showInSymbolList 12 | 1 13 | symbolTransformation 14 | s/^\s*func\s+/ / 15 | 16 | uuid 17 | E7FFE4C1-DDB7-4405-A669-41AB65734E12 18 | 19 | 20 | -------------------------------------------------------------------------------- /Preferences/Symbol List: Methods.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Symbol List: Methods 7 | scope 8 | source.go meta.function.receiver.declaration.go 9 | settings 10 | 11 | showInSymbolList 12 | 1 13 | symbolTransformation 14 | s/^\s*func\s+\(.*?\s+\*?(.*?)\)\s*/ $1./ 15 | 16 | uuid 17 | 52EBFA13-B3F1-42BA-AF98-6D632365184E 18 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # golang.tmbundle 2 | (a [TextMate 2](https://github.com/textmate/textmate) bundle for the [go programming language](https://golang.org)) 3 | 4 | ## Features 5 | 6 | - Syntax highlighting 7 | - Run, build, test, and install packages 8 | - Code completion with gocode 9 | - View documentation with gogetdoc (Requires Go 1.6+) 10 | - Formatting with gofmt 11 | - Automatic imports with goimports 12 | - Linting with golint 13 | - Multiple linters supported with gometalinter 14 | - Rename go identifiers with gorename 15 | - Find symbol information with godef 16 | - 45 snippets 17 | 18 | ## Installation 19 | TextMate should detect .go files and load this bundle automatically. Syntax highlighting will work, but commands may not. 20 | 21 | This bundle relies on amazing open source tooling for some functionality. These utilities can be installed with the following commands: 22 | 23 | Command | Use 24 | ------- | --- 25 | go get -u github.com/nsf/gocode | Code completion 26 | go get -u github.com/zmb3/gogetdoc | Documentation 27 | go get -u golang.org/x/tools/cmd/goimports | Package import resolution/rewriting 28 | go get -u github.com/golang/lint/golint | Standard linter 29 | go get -u github.com/alecthomas/gometalinter | Combination of multiple linters 30 | go get -u github.com/rogpeppe/godef | goto definition 31 | go get -u golang.org/x/tools/cmd/gorename | Rename go identifiers 32 | 33 | ### TextMate Variables 34 | TextMate does not inherit the users environment unless it is launched from the command line. 35 | You may have to set TM_GOPATH and GOROOT inside of TextMate for all functionality to work. 36 | You do not have to set TM_GOPATH if your GOPATH is ~/go and you are running [Go >1.8](https://golang.org/doc/go1.8#gopath). 37 | You do not have to set GOROOT in most circumstances. See [here](https://dave.cheney.net/2013/06/14/you-dont-need-to-set-goroot-really) for more information. 38 | 39 | You may override the following TextMate variables in the preferences, but most of these should be unnecessary (adjust paths to your own configuration): 40 | 41 | Variable | Suggested location 42 | -------- | ------------------ 43 | TM_GO | /usr/local/bin/go 44 | TM_GOPATH | /Users/myuser/go 45 | GOROOT | /usr/local/opt/go/libexec 46 | TM_GOFMT | /Users/myuser/go/bin/gofmt OR TM_GOFMT=/Users/myuser/go/bin/goimports for automatic import resolution on file save 47 | TM_GOCODE | /Users/myuser/go/bin/gocode 48 | TM_GOGETDOC | /Users/myuser/go/bin/gogetdoc 49 | TM_GOIMPORTS | /Users/myuser/go/bin/goimports 50 | TM_GOLINT | /Users/myuser/go/bin/golint 51 | TM_GODEF | /Users/myuser/go/bin/godef 52 | TM_GOMETALINTER | /Users/myuser/go/bin/gometalinter 53 | TM_GORENAME | /Users/myuser/go/bin/gorename 54 | 55 | ## Commands 56 | 57 | Shortcut | Content 58 | ------- | ------- 59 | Cmd-R | Compile and run the current file. 60 | Cmd-Shift-R | Compile and test the current package. 61 | Cmd-B | Build the current package. 62 | Cmd-Shift-I | Install the current package. 63 | Cmd-Shift-D | Open either a package listed in imports or a user-supplied package. 64 | Ctrl-H | Show the Go HTML documentation for the currently-selected symbol. 65 | Cmd-D | Go to the original definition of the currently selected symbol. 66 | Ctrl-Shift-H | Reformat the document according to the Go style guidelines, automatically resolve imports. 67 | Ctrl-Shift-L | Run 'go lint' 68 | Ctrl-Shift-M | Run the default linters supplied by gometalinter 69 | Ctrl-Shift-V | Run 'go vet' 70 | Opt-ESC | Complete the symbol under the cursor. 71 | 72 | ## Snippets 73 | 74 | ### Simple Statements 75 | 76 | Snippet | Content 77 | ------- | ------- 78 | Cmd-i | '+iota+' 79 | , | A pair ('first, second'), suitable for declaring result variables from a multi-return-value function or a map range loop. 80 | < | Send/receive through a channel. Provides tab stops for the value and the channel name. 81 | def | A default clause within a switch. 82 | fmt | fmt.Println with tab stop for interface 83 | fmt. | fmt.Printf with tab stops for string and interface 84 | in | An empty interface type (i.e. matches anything). 85 | imp | An import statement with optional alternative name. 86 | imps | A multiple-import statement. 87 | pkg | A package declaration including an optional comment block for packages other than 'main'. 88 | ret | A return statement with optional return value. 89 | 90 | ### Initializers and Declarations 91 | 92 | Snippet | Content 93 | ------- | ------- 94 | : | A short-form variable initializer (i.e. 'name := value'). 95 | \[\] | A slice variable type; expands to '[]+type+', so is usable inside other snippets. 96 | ch | A channel type. 97 | con | A single constant declaration. 98 | cons | A multiple constant declaration block. 99 | fun | A function type definition statement. 100 | inte | An interface definition with a single method. 101 | mk | A make statement (used for creating & initializing channels, maps, etc.). 102 | map | A map variable type; expands to 'map[+keytype+]+valuetype+'. 103 | ew | A new statement (used to create & initialize structure types). 104 | st | A struct definition with a single member. 105 | type | A type declaration, with name and variable type as tab-stops. 106 | types | A block with multiple type declarations. 107 | var | Declare a variable with an optional initial value (long form, i.e. 'var x int = 10'). 108 | vars | A block of long-form variable declarations. 109 | 110 | ### Functions 111 | 112 | Snippet | Content 113 | ------- | ------- 114 | de | A deferred goroutine call (defines the function inline). 115 | func | A plain (global) function declaration, with tab stops for name, parameters, and a single optional result. 116 | funcv | A plain (global) function declaration, with tab stops for name, parameters, and multiple results. 117 | go | An immediate goroutine call (defines the function inline). 118 | init | A template for a module's +init()+ function, with a tab stop at its body. 119 | main | A template for a +main()+ function with a tab stop at its body. 120 | meth | Declares a function on a particular type, with additional tab stops for receiver name and type and a single optional result. 121 | methv | Declares a function on a particular type, with additional tab stops for receiver name and type and multiple results. 122 | 123 | ### Control Statements 124 | 125 | Snippet | Content 126 | ------- | ------- 127 | case | A case clause, within a switch or select. 128 | for | A for loop. 129 | fori | A for loop with an index (similar to C for loops). 130 | forr | A for loop iterating over a collection's full range. 131 | if | An if statement, properly formatted (Go requires the use of {} on ifs, unlike C; this throws me sometimes). 132 | sel | A select statement, for looping over channel conditions. 133 | sw | A switch statement with an optional expression. 134 | 135 | ## Thanks 136 | 137 | This repository is a fork from [Jim Dovey's bundle](https://github.com/AlanQuatermain/go-tmbundle) with additional improvements merged from around the community. 138 | Changes from the original version (see git log for more details): 139 | 140 | - Substantially improved syntax highlighting (thanks [nanoant](https://github.com/nanoant)) 141 | - Support for goimports and golint (thanks [fmccann](https://github.com/fmccann)) 142 | - Support for godef (thanks [taterbase](https://github.com/taterbase)) 143 | - Users can supply commands via ENV variables (TM\_GO\_DYNAMIC\_GOPATH, TM\_GO\_DYNAMIC\_PKG, TM\_GO\_DYNAMIC\_PKG\_PATH). The bundle will consult these commands if defined to dynamically change the gopath or package based on the current directory. (thanks [fmccann](https://github.com/fmccann)) 144 | - all non-run go commands operate on the current directory instead of per file if the package is not defined dynamically. (thanks [tg](https://github.com/tg)). 145 | - run and build work on unsaved files (thanks [tg](https://github.com/tg)) 146 | - added print, println, printf, and fprintf snippets; improved struct snippet (thanks 147 | [jish](https://github.com/jish)) 148 | - HiDPI completion icons (thanks [nanoant](https://github.com/nanoant)) 149 | - Bug fixes and improvements (thanks [msoap](https://github.com/msoap)) 150 | - Improved, expanded documentation coverage (thanks [syscrusher](https://github.com/syscrusher)) 151 | - Completion support for GOPATH and current package (thanks [syscrusher](https://github.com/syscrusher)) 152 | - bugfixes (thanks everyone!) 153 | 154 | [Jim Dovey](https://github.com/AlanQuatermain) deserves everyone's gratitude for his hard work on this bundle. The following are his original attributions: 155 | >Much of the current infrastructure was created by [Martin Kühl](http://github.com/mkhl), who is a significantly more seasoned TextMate bundle developer than I, and to whom I am eternally grateful. 156 | 157 | >Support for Go 1.0 was provided by [Jeremy Whitlock](http://github.com/whitlockjc) and [Michael Sheets](http://github.com/infininight), with additional code and fixes from [Sylvain Defresne](http://github.com/sdefresne), [liuyork](http://github.com/liuyork), and [Alexey Palazhchenko](http://github.com/AlekSi). 158 | 159 | >Thanks be to lasersox and Infininight over at the [#textmate room on IRC](irc://irc.freenode.net/textmate) for all their help in cleaning up this here bundle, and for helping me to optimize my regex use in the language grammar. 160 | Thanks to Martin Kühl for his extensive additions to this project's snippets and commands. Also Infininight's work on updating the bundle to use the TextMate's new Ruby interface and Jeremy & Sylvain's work on supporting Go 1.0 has been invaluable. Their assistance and stewardship while I've been deep in the world of Objective-C is very much appreciated. 161 | 162 | Happy coding :) 163 | -------------------------------------------------------------------------------- /Snippets/Case Clause.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | case ${1:condition}: 7 | ${0://body} 8 | name 9 | Case Clause 10 | scope 11 | source.go 12 | tabTrigger 13 | case 14 | uuid 15 | EA490E02-1982-4F35-BBE5-D0B3DBCF148C 16 | 17 | 18 | -------------------------------------------------------------------------------- /Snippets/Channel.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | chan ${1:valtype} 7 | name 8 | Channel 9 | scope 10 | source.go 11 | tabTrigger 12 | ch 13 | uuid 14 | C71F1625-B79B-463B-961D-D2071BF21821 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Constant.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | const ${1:name}${2/(.+)/ /}${2:type} = ${0:value} 7 | name 8 | Constant 9 | scope 10 | source.go 11 | tabTrigger 12 | con 13 | uuid 14 | E3553899-14C9-4B7E-ABF5-A1C14A33808C 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Constants.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | const ( 7 | ${1:name}${2/(.+)/ /}${2:type} = ${0:value} 8 | ) 9 | name 10 | Constants 11 | scope 12 | source.go 13 | tabTrigger 14 | cons 15 | uuid 16 | 7B2D69FC-DFEA-4548-91B7-4A698E63F22D 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Default Clause.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | default: 7 | ${0://body} 8 | name 9 | Default Clause 10 | scope 11 | source.go 12 | tabTrigger 13 | def 14 | uuid 15 | C4732003-866C-466B-B72A-5FB209F46671 16 | 17 | 18 | -------------------------------------------------------------------------------- /Snippets/Deferred Call.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | defer ${1:func(${2:params}) { 7 | ${0:// body} 8 | \}(${3:${2/(.+)?/(?1:values)/}})} 9 | name 10 | Deferred Goroutine Call 11 | scope 12 | source.go 13 | tabTrigger 14 | de 15 | uuid 16 | 92CF0E27-7ED9-4F9B-8061-DD2B38D22893 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Empty Interface.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | interface {} 7 | name 8 | Empty Interface 9 | scope 10 | source.go 11 | tabTrigger 12 | in 13 | uuid 14 | E5E46A13-E5D3-49A3-9BFF-082A9DC69C08 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/For Index Loop.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | for ${2:i} := 0; $2 < ${1:count}; ${3:$2++} { 7 | ${0:// body} 8 | } 9 | name 10 | For Index Loop 11 | scope 12 | source.go 13 | tabTrigger 14 | fori 15 | uuid 16 | 7DA0072A-BF35-413B-B4D9-B5C2B4D20FF2 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/For Loop.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | for ${1:condition}${1/(.+)/ /}{ 7 | ${0:// body} 8 | } 9 | name 10 | For Loop 11 | scope 12 | source.go 13 | tabTrigger 14 | for 15 | uuid 16 | D58425E7-F6E5-4249-8C57-277C4E38A5F4 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/For Range Loop.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | for ${2:name} := range ${1:collection} { 7 | ${0:// body} 8 | } 9 | name 10 | For Range Loop 11 | scope 12 | source.go 13 | tabTrigger 14 | forr 15 | uuid 16 | 8C557B1F-C1C5-4FC3-830E-9D51DE6CFA5A 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Fprintf.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | fmt.Fprintf(${1:w}, ${2:"${3:Hello World!}"})$0 7 | name 8 | Fprintf 9 | scope 10 | source.go 11 | tabTrigger 12 | fmt. 13 | uuid 14 | 3AC6807B-E0F6-4D68-90E9-A19A0F5F0176 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Function Type.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | func(${4:params})${5/(.+)/ /}${5:type} 7 | name 8 | Function Type 9 | scope 10 | source.go 11 | tabTrigger 12 | fun 13 | uuid 14 | D6C5D7C0-06B6-4080-8E2B-8C646CADDE8C 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Function w: result vars.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | func${3/(.+)/ /}${3:name}(${4:params}) (${5:type}) { 7 | ${0:// body} 8 | } 9 | name 10 | Function w/ result vars 11 | scope 12 | source.go 13 | tabTrigger 14 | funcv 15 | uuid 16 | 65FCDB2E-8AD1-4FF4-8E0E-DD4511A461F5 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Function.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | func${3/(.+)/ /}${3:name}(${4:params})${5/(.+)/ /}${5:type} { 7 | ${0:// body} 8 | } 9 | name 10 | Function 11 | scope 12 | source.go 13 | tabTrigger 14 | func 15 | uuid 16 | E9B44CC5-B004-4793-B125-7E429FDCCE32 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Goroutine Call.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | go ${1:func(${2:params}) { 7 | ${0:// body} 8 | \}(${3:${2/(.+)?/(?1:values)/}})} 9 | name 10 | Goroutine Call 11 | scope 12 | source.go 13 | tabTrigger 14 | go 15 | uuid 16 | 6B01E886-4CFA-476E-AE01-EFF406116978 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/If Statement.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | if ${1:condition}${1/(.+)/ /}{ 7 | ${0:// body} 8 | } 9 | name 10 | If Statement 11 | scope 12 | source.go 13 | tabTrigger 14 | if 15 | uuid 16 | AF797914-E5F7-4F2B-866B-852889C6A925 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/If err.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | if ${1:err} != nil { 7 | ${2:log.Fatal($1)} 8 | }${0} 9 | name 10 | If err 11 | scope 12 | source.go 13 | tabTrigger 14 | ife 15 | uuid 16 | 8C0BE817-6C6E-4927-85E5-9DA3FB8A7000 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Import.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | import${2/(.+)/ /}${2:$1} "${1:package}" 7 | name 8 | Import 9 | scope 10 | source.go 11 | tabTrigger 12 | imp 13 | uuid 14 | 2DFA9510-6F88-4BC6-A409-DA4075DEA8FF 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Imports.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | import ( 7 | "${0:package}" 8 | ) 9 | name 10 | Imports 11 | scope 12 | source.go 13 | tabTrigger 14 | imps 15 | uuid 16 | 5E6327B4-8BD5-4079-8B25-D8D3EF9E89FB 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Init Function.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | func init() { 7 | ${0:// body} 8 | } 9 | name 10 | Init Function 11 | scope 12 | source.go 13 | tabTrigger 14 | init 15 | uuid 16 | 54394BD4-1FFE-440F-9D3D-2D44F3B1BCC6 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Initialize.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | ${1:name} := ${0:value} 7 | name 8 | Initialize 9 | scope 10 | source.go 11 | tabTrigger 12 | : 13 | uuid 14 | FAE480BF-DF92-4B4F-8982-AB61CD05AD64 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Interface.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | interface { 7 | ${0:method} 8 | } 9 | name 10 | Interface 11 | scope 12 | source.go 13 | tabTrigger 14 | inte 15 | uuid 16 | 96C65CC5-19C3-4B73-A66B-F9C80B98DE54 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Main Function.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | func main() { 7 | ${0:// body} 8 | } 9 | name 10 | Main Function 11 | scope 12 | source.go 13 | tabTrigger 14 | main 15 | uuid 16 | 18A04BC9-D37A-46B9-8C92-4E8D287A46E4 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Make.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | ${1:name}${1/(.+)/ := /}make(${2:reftype}) 7 | name 8 | Make 9 | scope 10 | source.go 11 | tabTrigger 12 | mk 13 | uuid 14 | 56603467-E883-4DB7-9562-62B841DC07CF 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Map.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | map[${1:keytype}]${2:valtype} 7 | name 8 | Map 9 | scope 10 | source.go 11 | tabTrigger 12 | map 13 | uuid 14 | 95F0EB07-61D5-4E0C-B610-BFD4A802A5C3 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Method w: result vars.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | func (${1:receiver} ${2:type}) ${3:name}(${4:params}) (${5:type}) { 7 | ${0:// body} 8 | } 9 | name 10 | Method w/ result vars 11 | scope 12 | source.go 13 | tabTrigger 14 | methv 15 | uuid 16 | 0DF6CCE2-56DF-43EF-8EEE-BDFFEC38C244 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Method.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | func (${1:receiver} ${2:type}) ${3:name}(${4:params})${5/(.+)/ /}${5:type} { 7 | ${0:// body} 8 | } 9 | name 10 | Method 11 | scope 12 | source.go 13 | tabTrigger 14 | meth 15 | uuid 16 | D8CF6ACF-85BB-4AAD-BFDE-DFD9D075FCF2 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/New.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | ${1:name}${1/(.+)/ := /}new(${2:type}) 7 | name 8 | New 9 | scope 10 | source.go 11 | tabTrigger 12 | new 13 | uuid 14 | 8FC95B21-86DE-4E94-889E-FE1472F1E25F 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Package.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | ${1/^main$|(.+)/(?1:/* 7 | The $1 package implements ... bananas? 8 | */ 9 | )/}package ${1:main} 10 | name 11 | Package 12 | scope 13 | source.go 14 | tabTrigger 15 | pkg 16 | uuid 17 | CFE21C25-71DE-48A9-8FE6-2A40D8DF16EF 18 | 19 | 20 | -------------------------------------------------------------------------------- /Snippets/Pair.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | ${1:first}, ${0:second} 7 | name 8 | Pair 9 | scope 10 | source.go 11 | tabTrigger 12 | , 13 | uuid 14 | 0FC09B94-D4C1-4C21-8076-EE7075174926 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Print.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | fmt.Print(${1:"${2:Hello World!}"})$0 7 | name 8 | Print 9 | scope 10 | source.go 11 | tabTrigger 12 | fmt. 13 | uuid 14 | 6FCDC940-B46E-44E0-84F4-F2296EB17106 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Printf.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | fmt.Printf(${1:"${2:Hello World!}"}, $3)$0 7 | name 8 | Printf 9 | scope 10 | source.go 11 | tabTrigger 12 | fmt. 13 | uuid 14 | 12AC27D2-4B5D-467D-AA52-1C8AACF753E7 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Return Statement.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | return${1/(.+)/ /}${1:value} 7 | name 8 | Return Statement 9 | scope 10 | source.go 11 | tabTrigger 12 | ret 13 | uuid 14 | 4B3F378E-D9E8-4CCB-B537-96099B406511 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Select Statement.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | select { 7 | case${0} 8 | } 9 | name 10 | Select Statement 11 | scope 12 | source.go 13 | tabTrigger 14 | sel 15 | uuid 16 | 26577C1F-0975-4A8F-BB89-375B0908FCA2 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Send_Receive.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | ${1:channel}${1/(.+)/ /}<-${0:${1/(.+)?/(?1: value:channel)/)}} 7 | name 8 | Send/Receive 9 | scope 10 | source.go 11 | tabTrigger 12 | < 13 | uuid 14 | 0E515A1F-B6F7-4473-B4C6-D6485E7CD133 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Slice.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | []${1:valtype} 7 | name 8 | Slice 9 | scope 10 | source.go 11 | tabTrigger 12 | [] 13 | uuid 14 | 22E438EE-F254-4FB3-B05E-BA59387E3F6F 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Struct.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | type ${1:Foo} struct { 7 | ${2:Bar} ${0:string} 8 | } 9 | name 10 | Struct 11 | scope 12 | source.go 13 | tabTrigger 14 | st 15 | uuid 16 | CC5D7F66-6BBC-4D9C-BC32-D569238523EB 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Switch Statement.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | switch ${1:expression}${1/(.+)/ /}{ 7 | case${0} 8 | } 9 | name 10 | Switch Statement 11 | scope 12 | source.go 13 | tabTrigger 14 | sw 15 | uuid 16 | DE6B5489-7140-4954-AA78-6C4014525D38 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Test.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | package ${1:`base="${TM_FILEPATH%_test.go}.go" 7 | if [[ -f "$base" ]] && grep -q '^package ' "$base" 8 | then grep -m1 '^package ' "$base"|cut -d' ' -f2 9 | else echo 'main' 10 | fi`} 11 | 12 | import ( 13 | "testing" 14 | ) 15 | 16 | func Test${2:${TM_DISPLAYNAME/^(.*?)(_test)?(\.go)?$/${1:/capitalize}/}}(t *testing.T) { 17 | $0t.Fatal("no test body") 18 | } 19 | name 20 | Test 21 | scope 22 | source.go 23 | tabTrigger 24 | test 25 | uuid 26 | C6F66AFB-B50B-45AF-B2B2-819CC3464E56 27 | 28 | 29 | -------------------------------------------------------------------------------- /Snippets/Type.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | type ${1:name} ${0:definition} 7 | name 8 | Type 9 | scope 10 | source.go 11 | tabTrigger 12 | type 13 | uuid 14 | 9E325583-D146-41A4-BA94-0B5BF91DEBF8 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Types.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | type ( 7 | ${1:name} ${0:definition} 8 | ) 9 | name 10 | Types 11 | scope 12 | source.go 13 | tabTrigger 14 | types 15 | uuid 16 | F4CA0BAC-E987-4154-BCBA-35B2668D514D 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/Variable.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}} 7 | name 8 | Variable 9 | scope 10 | source.go 11 | tabTrigger 12 | var 13 | uuid 14 | E86778CD-D0DE-4E2E-AB13-740FA3E79814 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/Variables.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | var ( 7 | ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}} 8 | ) 9 | name 10 | Variables 11 | scope 12 | source.go 13 | tabTrigger 14 | vars 15 | uuid 16 | 113FC085-6E3C-432A-A2F1-D8BD54B8B49E 17 | 18 | 19 | -------------------------------------------------------------------------------- /Snippets/fmt_Println.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | fmt.Println(${1:"${2:Hello World!}"})$0 7 | name 8 | Print line 9 | scope 10 | source.go 11 | tabTrigger 12 | fmt 13 | uuid 14 | F5E717F6-A08B-4766-B1D5-0E43C796FDE1 15 | 16 | 17 | -------------------------------------------------------------------------------- /Snippets/iota.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | iota 7 | keyEquivalent 8 | @i 9 | name 10 | Iota 11 | scope 12 | source.go 13 | uuid 14 | DCF037CD-EF51-41BA-A29B-3184FB48685F 15 | 16 | 17 | -------------------------------------------------------------------------------- /Support/HELP.md: -------------------------------------------------------------------------------- 1 | # Setup 2 | This bundle relies on amazing open source tooling for some functionality. These utilities can be installed with the following commands: 3 | 4 | go get -u github.com/nsf/gocode # completion 5 | go get -u github.com/zmb3/gogetdoc # documentation 6 | go get -u golang.org/x/tools/cmd/goimports # import resolution/rewriting 7 | go get -u github.com/golang/lint/golint # linting 8 | go get -u github.com/rogpeppe/godef # goto definition 9 | go get -u github.com/alecthomas/gometalinter # metalinting 10 | 11 | You may override the following TextMate variables in the preferences (adjust paths to your own configuration). TextMate does not inherit the users environment unless it is launched from the command line. It may be necessary to set TM_GOPATH and GOROOT. 12 | 13 | TM_GO=/usr/local/bin/go 14 | TM_GOPATH=/Users/myuser/go 15 | TM_GOCODE=/Users/myuser/bin/gocode 16 | TM_GOGETDOC=/Users/myuser/bin/gogetdoc 17 | TM_GOFMT=/Users/myuser/bin/gofmt # or /Users/myuser/bin/goimports 18 | TM_GOIMPORTS=/Users/myuser/bin/goimports 19 | TM_GOLINT=/Users/myuser/bin/golint 20 | TM_GODEF=/Users/myuser/bin/godef 21 | TM_GOMETALINTER=/Users/myuser/bin/gometalinter 22 | 23 | # Further Help 24 | The full documentation is available on [GitHub](https://github.com/syscrusher/golang.tmbundle/blob/master/README.md), including commands and snippets. -------------------------------------------------------------------------------- /Support/go_setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | if [ -z "${GOPATH}" ]; then 3 | export GOPATH="${TM_GOPATH}" 4 | fi 5 | -------------------------------------------------------------------------------- /Support/gomate.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby -wKU 2 | 3 | require ENV['TM_SUPPORT_PATH'] + '/lib/exit_codes' 4 | require ENV['TM_SUPPORT_PATH'] + '/lib/textmate' 5 | require ENV['TM_SUPPORT_PATH'] + '/lib/tm/executor' 6 | require ENV['TM_SUPPORT_PATH'] + '/lib/tm/process' 7 | require ENV['TM_SUPPORT_PATH'] + '/lib/tm/save_current_document' 8 | 9 | # TextMate's special GOPATH used in .tm_properties files prepended to the environment's GOPATH 10 | ENV['GOPATH'] = (ENV.has_key?('TM_GOPATH') ? ENV['TM_GOPATH'] : '') + 11 | (ENV.has_key?('GOPATH') ? ':' + ENV['GOPATH'] : '').sub(/^:+/,'') 12 | 13 | # Call tool to determine gopath 14 | if ENV.has_key?('TM_GO_DYNAMIC_GOPATH') 15 | Dir.chdir(ENV['TM_DIRECTORY']) do 16 | ENV['GOPATH'] = `#{ENV['TM_GO_DYNAMIC_GOPATH']}`.chomp 17 | end 18 | end 19 | 20 | module Go 21 | def Go::go(command, options={}) 22 | # TextMate's special TM_GO or expect 'go' on PATH 23 | go_cmd = ENV['TM_GO'] || 'go' 24 | 25 | TextMate.save_if_untitled('go') 26 | TextMate::Executor.make_project_master_current_document 27 | 28 | args = options[:args] ? options[:args] : [] 29 | opts = {:use_hashbang => false, :version_args => ['version'], :version_regex => /\Ago version (.*)/} 30 | opts[:verb] = options[:verb] if options[:verb] 31 | 32 | # Default to running against directory, which in go should be the package. 33 | # Doesn't hold for "go run", which needs to be executed against the file. 34 | # The same will happend if directory is not set. 35 | directory = ENV['TM_DIRECTORY'] 36 | if directory 37 | opts[:chdir] = directory 38 | end 39 | 40 | # Call tool to determine package; default to directory name 41 | pkg = directory 42 | if ENV.has_key?('TM_GO_DYNAMIC_PKG') 43 | Dir.chdir(ENV['TM_DIRECTORY']) do 44 | pkg = `#{ENV['TM_GO_DYNAMIC_PKG']}`.chomp 45 | pkg = nil if pkg == nil || pkg.empty? 46 | end 47 | end 48 | 49 | if command == 'run' || !pkg 50 | args.push(ENV['TM_FILEPATH']) 51 | else 52 | args.push("-v") # list packages being operated on 53 | opts[:noun] = pkg 54 | end 55 | args.push(opts) 56 | 57 | TextMate::Executor.run(go_cmd, command, *args) 58 | end 59 | 60 | def Go::gogetdoc 61 | # TextMate's special TM_GOGETDOC or expect 'gogetdoc' on PATH 62 | gogetdoc_cmd = ENV['TM_GOGETDOC'] || 'gogetdoc' 63 | 64 | # Save file. gogetdoc only accepts guru's archive format, which we don't currently support 65 | TextMate.save_if_untitled('go') 66 | 67 | # load current document from stdin 68 | document = [] 69 | while line = $stdin.gets 70 | document.push(line) 71 | end 72 | 73 | # byte offset of cursor position from the beginning of file 74 | cursor = document[ 0, ENV['TM_LINE_NUMBER'].to_i - 1].join().length + ENV['TM_LINE_INDEX'].to_i 75 | 76 | args = [] 77 | args.push(gogetdoc_cmd) 78 | args.push('-pos') 79 | args.push("#{ENV['TM_FILEPATH']}:##{cursor}") 80 | 81 | out, err = TextMate::Process.run(*args) 82 | 83 | if err.nil? || err == '' 84 | if out.length < 400 85 | TextMate.exit_show_tool_tip(out) 86 | else 87 | TextMate.exit_create_new_document(out) 88 | end 89 | else 90 | TextMate.exit_show_tool_tip(err) 91 | end 92 | 93 | end 94 | 95 | def Go::golint 96 | golint = ENV['TM_GOLINT'] || 'golint' 97 | TextMate.save_if_untitled('go') 98 | TextMate::Executor.make_project_master_current_document 99 | 100 | args = Array.new 101 | opts = {:use_hashbang => false, :verb => 'Linting', :version_replace => 'golint'} 102 | 103 | file_length = ENV['TM_DIRECTORY'].length + 1 104 | go_file = ENV['TM_FILEPATH'][file_length..-1] 105 | opts[:chdir] = ENV['TM_DIRECTORY'] 106 | 107 | args.push(go_file) 108 | args.push(opts) 109 | 110 | TextMate::Executor.run(golint, *args) 111 | end 112 | 113 | def Go::gometalinter 114 | gometalinter = ENV['TM_GOMETALINTER'] || 'gometalinter' 115 | TextMate.save_if_untitled('go') 116 | 117 | args = Array.new 118 | opts = {:use_hashbang => false, :verb => 'MetaLinting', :version_replace => 'gometalinter'} 119 | 120 | args.push(ENV['TM_DIRECTORY']) 121 | args.push(opts) 122 | 123 | TextMate::Executor.run(gometalinter, *args) 124 | end 125 | end 126 | -------------------------------------------------------------------------------- /Support/icons/const.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/syscrusher/golang.tmbundle/5687580497a075969ca1c658c827ce690593e483/Support/icons/const.pdf -------------------------------------------------------------------------------- /Support/icons/func.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/syscrusher/golang.tmbundle/5687580497a075969ca1c658c827ce690593e483/Support/icons/func.pdf -------------------------------------------------------------------------------- /Support/icons/icons.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /Support/icons/package.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/syscrusher/golang.tmbundle/5687580497a075969ca1c658c827ce690593e483/Support/icons/package.pdf -------------------------------------------------------------------------------- /Support/icons/type.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/syscrusher/golang.tmbundle/5687580497a075969ca1c658c827ce690593e483/Support/icons/type.pdf -------------------------------------------------------------------------------- /Support/icons/var.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/syscrusher/golang.tmbundle/5687580497a075969ca1c658c827ce690593e483/Support/icons/var.pdf -------------------------------------------------------------------------------- /Syntaxes/Go.tmLanguage: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | comment 6 | Go allows any Unicode character to be used in identifiers, so our identifier regex is: \b([[:alpha:]_]+\w*)\b 7 | cf. The Go Programming Language Specification <http://golang.org/doc/go_spec.html> 8 | fileTypes 9 | 10 | go 11 | 12 | firstLineMatch 13 | (?i)-[*]-\s*(mode:)?\s*go\s*-[*]- 14 | keyEquivalent 15 | ^~G 16 | name 17 | Go 18 | patterns 19 | 20 | 21 | include 22 | #receiver_function_declaration 23 | 24 | 25 | include 26 | #plain_function_declaration 27 | 28 | 29 | include 30 | #type_declaration 31 | 32 | 33 | include 34 | #basic_things 35 | 36 | 37 | include 38 | #exported_variables 39 | 40 | 41 | begin 42 | ^\s*(import)\b\s+ 43 | beginCaptures 44 | 45 | 1 46 | 47 | name 48 | keyword.control.import.go 49 | 50 | 51 | end 52 | (?=(?://|/\*))|$ 53 | name 54 | meta.preprocessor.go.import 55 | patterns 56 | 57 | 58 | begin 59 | " 60 | beginCaptures 61 | 62 | 0 63 | 64 | name 65 | punctuation.definition.string.begin.go 66 | 67 | 68 | end 69 | " 70 | endCaptures 71 | 72 | 0 73 | 74 | name 75 | punctuation.definition.string.end.go 76 | 77 | 78 | name 79 | string.quoted.double.import.go 80 | 81 | 82 | 83 | 84 | include 85 | #block 86 | 87 | 88 | include 89 | #root_parens 90 | 91 | 92 | include 93 | #function_calls 94 | 95 | 96 | repository 97 | 98 | access 99 | 100 | match 101 | (?<=\.)[[:alpha:]_]\w*\b(?!\s*\() 102 | name 103 | variable.other.dot-access.go 104 | 105 | basic_things 106 | 107 | patterns 108 | 109 | 110 | include 111 | #comments 112 | 113 | 114 | include 115 | #initializers 116 | 117 | 118 | include 119 | #access 120 | 121 | 122 | include 123 | #strings 124 | 125 | 126 | include 127 | #keywords 128 | 129 | 130 | 131 | block 132 | 133 | begin 134 | \{ 135 | beginCaptures 136 | 137 | 0 138 | 139 | name 140 | punctuation.section.block.begin.go 141 | 142 | 143 | end 144 | \} 145 | endCaptures 146 | 147 | 0 148 | 149 | name 150 | punctuation.section.block.end.go 151 | 152 | 153 | name 154 | meta.block.go 155 | patterns 156 | 157 | 158 | include 159 | #block_innards 160 | 161 | 162 | 163 | block_innards 164 | 165 | patterns 166 | 167 | 168 | include 169 | #function_block_innards 170 | 171 | 172 | include 173 | #exported_variables 174 | 175 | 176 | 177 | comments 178 | 179 | patterns 180 | 181 | 182 | captures 183 | 184 | 1 185 | 186 | name 187 | meta.toc-list.banner.block.go 188 | 189 | 190 | match 191 | ^/\* =(\s*.*?)\s*= \*/$\n? 192 | name 193 | comment.block.go 194 | 195 | 196 | begin 197 | /\* 198 | captures 199 | 200 | 0 201 | 202 | name 203 | punctuation.definition.comment.go 204 | 205 | 206 | end 207 | \*/ 208 | name 209 | comment.block.go 210 | 211 | 212 | match 213 | \*/.*\n 214 | name 215 | invalid.illegal.stray-comment-end.go 216 | 217 | 218 | captures 219 | 220 | 1 221 | 222 | name 223 | punctuation.definition.comment.go 224 | 225 | 2 226 | 227 | name 228 | meta.toc-list.banner.line.go 229 | 230 | 231 | match 232 | ^(//) =(\s*.*?)\s*=\s*$\n? 233 | name 234 | comment.line.double-slash.banner.go 235 | 236 | 237 | begin 238 | (^[ \t]+)?(?=//) 239 | beginCaptures 240 | 241 | 1 242 | 243 | name 244 | punctuation.whitespace.comment.leading.go 245 | 246 | 247 | end 248 | (?!\G) 249 | patterns 250 | 251 | 252 | begin 253 | // 254 | beginCaptures 255 | 256 | 0 257 | 258 | name 259 | punctuation.definition.comment.go 260 | 261 | 262 | end 263 | \n 264 | name 265 | comment.line.double-slash.go 266 | patterns 267 | 268 | 269 | match 270 | (?>\\\s*\n) 271 | name 272 | punctuation.separator.continuation.go 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | exported_variables 281 | 282 | comment 283 | This is kinda hacky, in order to get the 'var' scoped the right way again. 284 | match 285 | (?<=\s|\[\])([[:upper:]]\w*)(?=\W+) 286 | name 287 | variable.other.exported.go 288 | 289 | fn_parens 290 | 291 | begin 292 | \( 293 | beginCaptures 294 | 295 | 0 296 | 297 | name 298 | punctuation.section.parens.begin.go 299 | 300 | 301 | end 302 | \) 303 | endCaptures 304 | 305 | 0 306 | 307 | name 308 | punctuation.section.parens.end.go 309 | 310 | 311 | name 312 | meta.parens.go 313 | patterns 314 | 315 | 316 | include 317 | #basic_things 318 | 319 | 320 | include 321 | #function_calls 322 | 323 | 324 | 325 | function_block 326 | 327 | begin 328 | \{ 329 | beginCaptures 330 | 331 | 0 332 | 333 | name 334 | punctuation.section.function-block.begin.go 335 | 336 | 337 | end 338 | \} 339 | endCaptures 340 | 341 | 0 342 | 343 | name 344 | punctuation.section.function-block.end.go 345 | 346 | 347 | name 348 | meta.block.go 349 | patterns 350 | 351 | 352 | include 353 | #function_block_innards 354 | 355 | 356 | 357 | function_block_innards 358 | 359 | patterns 360 | 361 | 362 | include 363 | #basic_things 364 | 365 | 366 | captures 367 | 368 | 1 369 | 370 | name 371 | punctuation.whitespace.support.function.leading.go 372 | 373 | 2 374 | 375 | name 376 | support.function.builtin.go 377 | 378 | 379 | match 380 | (\s*)\b(new|c(lose|ap)|p(anic|rint(ln)?)|len|make|append)(?:\b|\() 381 | 382 | 383 | include 384 | #function_block 385 | 386 | 387 | include 388 | #function_calls 389 | 390 | 391 | include 392 | #fn_parens 393 | 394 | 395 | 396 | function_calls 397 | 398 | captures 399 | 400 | 1 401 | 402 | name 403 | punctuation.whitespace.function-call.leading.go 404 | 405 | 2 406 | 407 | name 408 | support.function.any-method.go 409 | 410 | 3 411 | 412 | name 413 | punctuation.definition.parameters.go 414 | 415 | 416 | match 417 | (?x) 418 | (?: (?= \s ) (?:(?<=else|new|return) | (?<!\w)) (\s+) )? 419 | (\b 420 | (?!(for|if|else|switch|return)\s*\() 421 | (?:[[:alpha:]_]\w*+\b) # method name 422 | ) 423 | \s*(\() 424 | 425 | name 426 | meta.function-call.go 427 | 428 | initializers 429 | 430 | patterns 431 | 432 | 433 | captures 434 | 435 | 1 436 | 437 | name 438 | keyword.control.go 439 | 440 | 2 441 | 442 | patterns 443 | 444 | 445 | match 446 | [[:alpha:]_]\w* 447 | name 448 | variable.other.go 449 | 450 | 451 | 452 | 3 453 | 454 | patterns 455 | 456 | 457 | include 458 | #keywords 459 | 460 | 461 | match 462 | [[:alpha:]_]\w*\b(?!\.) 463 | name 464 | support.type.go 465 | 466 | 467 | 468 | 469 | comment 470 | This matches the 'var x' style of variable declaration. 471 | match 472 | ^\s*(var)\s+((?:[[:alpha:]_]\w*)(?:,\s+[[:alpha:]_]\w*)*)\s*(.*?)\s*(?:=|$) 473 | name 474 | meta.initialization.explicit.go 475 | 476 | 477 | captures 478 | 479 | 1 480 | 481 | patterns 482 | 483 | 484 | match 485 | [[:alpha:]_]\w* 486 | name 487 | variable.other.go 488 | 489 | 490 | 491 | 2 492 | 493 | name 494 | keyword.operator.go 495 | 496 | 3 497 | 498 | patterns 499 | 500 | 501 | include 502 | #keywords 503 | 504 | 505 | match 506 | [[:alpha:]_]\w*\b(?!\.) 507 | name 508 | support.type.go 509 | 510 | 511 | 512 | 513 | comment 514 | This matches the 'x :=' style of variable declaration. 515 | match 516 | ((?:[[:alpha:]_]\w*)(?:\s*,\s+[[:alpha:]_]\w*)*)\s*(:=)(?:\s*([[:alpha:]_]\w*)\s*\{)? 517 | name 518 | meta.initialization.short.go 519 | 520 | 521 | 522 | keywords 523 | 524 | patterns 525 | 526 | 527 | match 528 | \b(s(elect|witch)|c(ontinue|ase)|type|i(nterface|f|mport)|def(er|ault)|package|else|var|f(or|unc|allthrough)|r(eturn|ange)|go(to)?|break)\b 529 | name 530 | keyword.control.go 531 | 532 | 533 | match 534 | (\b|(?<=\]))(int(16|8|32|64)?|uint(16|8|32|64|ptr)?|rune|float(32|64)|complex(64|128)|b(yte|ool)|string|error|struct)\b 535 | name 536 | storage.type.go 537 | 538 | 539 | match 540 | \b(c(onst|han)|map)\b 541 | name 542 | storage.modifier.go 543 | 544 | 545 | match 546 | \b(nil|true|false|iota)\b 547 | name 548 | constant.language.go 549 | 550 | 551 | match 552 | \b((0(x|X)[0-9a-fA-F]*)|((\d+\.?\d*)|(\.\d+))((e|E)(\+|-)?\d+)?)\b 553 | name 554 | constant.numeric.go 555 | 556 | 557 | match 558 | \<\- 559 | name 560 | keyword.operator.channel.go 561 | 562 | 563 | 564 | plain_function_declaration 565 | 566 | begin 567 | (?x) 568 | (^\s*(func)\s* 569 | ([[:alpha:]_]\w*)? # name of function is optional 570 | \( ((?:[\[\]\w\d\s\/,._*&<>-]|(?:interface\{\}))*)? \) # required braces for parameters (even if empty) 571 | \s* 572 | (?: # optional return types 573 | (?: \( ((?:[\[\]\w\d\s,._*&<>-]|(?:interface\{\}))*) \) ) | # within braces 574 | (?: ((?:[\[\]\w\d\s,._*&<>-]|(?:interface\{\}))*) ) # without braces (just type) 575 | )? 576 | ) 577 | 578 | beginCaptures 579 | 580 | 1 581 | 582 | name 583 | meta.function.declaration.go 584 | 585 | 2 586 | 587 | name 588 | keyword.control.go 589 | 590 | 3 591 | 592 | name 593 | entity.name.function.go 594 | 595 | 4 596 | 597 | patterns 598 | 599 | 600 | captures 601 | 602 | 1 603 | 604 | name 605 | variable.parameter.go 606 | 607 | 608 | match 609 | (?<=[\(,])\s*([[:alpha:]_]\w*) 610 | 611 | 612 | include 613 | #keywords 614 | 615 | 616 | match 617 | [[:alpha:]_]\w*\b(?!\.) 618 | name 619 | support.type.parameter.go 620 | 621 | 622 | 623 | 5 624 | 625 | patterns 626 | 627 | 628 | captures 629 | 630 | 1 631 | 632 | name 633 | variable.parameter.return.go 634 | 635 | 636 | match 637 | (?<=[\(,])\s*([[:alpha:]_]\w*) 638 | 639 | 640 | include 641 | #keywords 642 | 643 | 644 | match 645 | [[:alpha:]_]\w*\b(?!\.) 646 | name 647 | support.type.return.go 648 | 649 | 650 | 651 | 6 652 | 653 | patterns 654 | 655 | 656 | include 657 | #keywords 658 | 659 | 660 | match 661 | [[:alpha:]_]\w*\b(?!\.) 662 | name 663 | support.type.return.go 664 | 665 | 666 | 667 | 668 | comment 669 | We scope all parenthesized alpha-numeric text as variable.parameter.go and storage.type.return.go, which is a bit lazy, as some of it is storage.type. 670 | end 671 | (?<=\}) 672 | name 673 | meta.function.plain.go 674 | patterns 675 | 676 | 677 | include 678 | #comments 679 | 680 | 681 | include 682 | #keywords 683 | 684 | 685 | include 686 | #function_block 687 | 688 | 689 | 690 | receiver_function_declaration 691 | 692 | begin 693 | (?x) 694 | ( 695 | (func)\s* 696 | ( 697 | \( ((?:[\[\]\w\d\s,._*&<>-]|(?:interface\{\}))*) \)\s+ # receiver variable declarations, in brackets 698 | ([[:alpha:]_]\w*)? # name of function is optional 699 | ) 700 | \( ((?:[\[\]\w\d\s,._*&<>-]|(?:interface\{\}))*)? \) # required braces for parameters (even if empty) 701 | \s* 702 | (?: # optional return types 703 | (?: \( ((?:[\[\]\w\d\s,._*&<>-]|(?:interface\{\}))*) \) ) | # within braces 704 | (?: ((?:[\[\]\w\d\s,._*&<>-]|(?:interface\{\}))*) ) # without braces (just type) 705 | )? 706 | ) 707 | 708 | beginCaptures 709 | 710 | 1 711 | 712 | name 713 | meta.function.receiver.declaration.go 714 | 715 | 2 716 | 717 | name 718 | keyword.control.go 719 | 720 | 3 721 | 722 | name 723 | entity.name.function.full-name.go 724 | 725 | 4 726 | 727 | patterns 728 | 729 | 730 | captures 731 | 732 | 1 733 | 734 | name 735 | variable.other.receiver.go 736 | 737 | 738 | match 739 | (?<=[\(,])\s*([[:alpha:]_]\w*) 740 | 741 | 742 | include 743 | #keywords 744 | 745 | 746 | match 747 | [[:alpha:]_]\w* 748 | name 749 | support.type.receiver.go 750 | 751 | 752 | 753 | 5 754 | 755 | name 756 | entity.name.function.go 757 | 758 | 6 759 | 760 | patterns 761 | 762 | 763 | captures 764 | 765 | 1 766 | 767 | name 768 | variable.parameter.go 769 | 770 | 771 | match 772 | (?<=[\(,])\s*([[:alpha:]_]\w*) 773 | 774 | 775 | include 776 | #keywords 777 | 778 | 779 | match 780 | [[:alpha:]_]\w*\b(?!\.) 781 | name 782 | support.type.parameter.go 783 | 784 | 785 | 786 | 7 787 | 788 | patterns 789 | 790 | 791 | captures 792 | 793 | 1 794 | 795 | name 796 | variable.parameter.return.go 797 | 798 | 799 | match 800 | (?<=[\(,])\s*([[:alpha:]_]\w*) 801 | 802 | 803 | include 804 | #keywords 805 | 806 | 807 | match 808 | [[:alpha:]_]\w*\b(?!\.) 809 | name 810 | support.type.return.go 811 | 812 | 813 | 814 | 8 815 | 816 | patterns 817 | 818 | 819 | include 820 | #keywords 821 | 822 | 823 | match 824 | [[:alpha:]_]\w*\b(?!\.) 825 | name 826 | support.type.return.go 827 | 828 | 829 | 830 | 831 | comment 832 | Version of above with support for declaring a receiver variable. 833 | end 834 | (?<=\}) 835 | name 836 | meta.function.receiver.go 837 | patterns 838 | 839 | 840 | include 841 | #comments 842 | 843 | 844 | include 845 | #keywords 846 | 847 | 848 | include 849 | #function_block 850 | 851 | 852 | 853 | root_parens 854 | 855 | begin 856 | \( 857 | end 858 | (?<=\()(\))?|(?:\)) 859 | endCaptures 860 | 861 | 1 862 | 863 | name 864 | meta.parens.empty.go 865 | 866 | 867 | name 868 | meta.parens.go 869 | patterns 870 | 871 | 872 | include 873 | #basic_things 874 | 875 | 876 | include 877 | #exported_variables 878 | 879 | 880 | include 881 | #function_calls 882 | 883 | 884 | 885 | string_escaped_char 886 | 887 | patterns 888 | 889 | 890 | match 891 | \\(\\|[abfnrutv'"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|[0-7]{3}) 892 | name 893 | constant.character.escape.go 894 | 895 | 896 | match 897 | \\. 898 | name 899 | invalid.illegal.unknown-escape.go 900 | 901 | 902 | 903 | string_placeholder 904 | 905 | patterns 906 | 907 | 908 | match 909 | (?x)% 910 | (\d+\$)? # field (argument #) 911 | [#0\- +']* # flags 912 | [,;:_]? # separator character (AltiVec) 913 | ((-?\d+)|\*(-?\d+\$)?)? # minimum field width 914 | (\.((-?\d+)|\*(-?\d+\$)?)?)? # precision 915 | (\[\d+\])? # argument index 916 | [diouxXDOUeEfFgGaAcCsSpnvtTbyYhHmMzZq%] # conversion type 917 | 918 | name 919 | constant.other.placeholder.go 920 | 921 | 922 | match 923 | % 924 | name 925 | invalid.illegal.placeholder.go 926 | 927 | 928 | 929 | strings 930 | 931 | patterns 932 | 933 | 934 | begin 935 | " 936 | beginCaptures 937 | 938 | 0 939 | 940 | name 941 | punctuation.definition.string.begin.go 942 | 943 | 944 | end 945 | " 946 | endCaptures 947 | 948 | 0 949 | 950 | name 951 | punctuation.definition.string.end.go 952 | 953 | 954 | name 955 | string.quoted.double.go 956 | patterns 957 | 958 | 959 | include 960 | #string_placeholder 961 | 962 | 963 | include 964 | #string_escaped_char 965 | 966 | 967 | 968 | 969 | begin 970 | ' 971 | beginCaptures 972 | 973 | 0 974 | 975 | name 976 | punctuation.definition.string.begin.go 977 | 978 | 979 | end 980 | ' 981 | endCaptures 982 | 983 | 0 984 | 985 | name 986 | punctuation.definition.string.end.go 987 | 988 | 989 | name 990 | string.quoted.single.go 991 | patterns 992 | 993 | 994 | include 995 | #string_escaped_char 996 | 997 | 998 | 999 | 1000 | begin 1001 | ` 1002 | beginCaptures 1003 | 1004 | 0 1005 | 1006 | name 1007 | punctuation.definition.string.begin.go 1008 | 1009 | 1010 | end 1011 | ` 1012 | endCaptures 1013 | 1014 | 0 1015 | 1016 | name 1017 | punctuation.definition.string.end.go 1018 | 1019 | 1020 | name 1021 | string.other.raw.go 1022 | 1023 | 1024 | 1025 | type_declaration 1026 | 1027 | captures 1028 | 1029 | 1 1030 | 1031 | name 1032 | keyword.control.go 1033 | 1034 | 2 1035 | 1036 | name 1037 | entity.name.type.exported.go 1038 | 1039 | 3 1040 | 1041 | name 1042 | entity.name.type.private.go 1043 | 1044 | 4 1045 | 1046 | patterns 1047 | 1048 | 1049 | include 1050 | #keywords 1051 | 1052 | 1053 | match 1054 | [[:alpha:]_]\w*\b(?!\.) 1055 | name 1056 | support.type.go 1057 | 1058 | 1059 | 1060 | 1061 | match 1062 | (?x) 1063 | ^\s*(type)\s* 1064 | (?:([[:upper:]]\w*)|([[:alpha:]_]\w*)) # name of type 1065 | ((?:[\[\]\w\d\s\/,._*&<>-]|(?:interface\{\}))*)? # other type 1066 | 1067 | name 1068 | meta.type.go 1069 | 1070 | 1071 | scopeName 1072 | source.go 1073 | uuid 1074 | 33100200-8916-4F78-8522-4362628C6889 1075 | 1076 | 1077 | -------------------------------------------------------------------------------- /Syntaxes/HTML (Go).tmLanguage: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | comment 6 | Go Template Specification <https://golang.org/pkg/text/template/> 7 | fileTypes 8 | 9 | tmpl 10 | 11 | foldingStartMarker 12 | (?x) 13 | (<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)\b.*?> 14 | |<!--(?!.*-->) 15 | |\{\s*($|\?>\s*$|//|/\*(.*\*/\s*$|(?!.*?\*/))) 16 | ) 17 | foldingStopMarker 18 | (?x) 19 | (</(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)> 20 | |^\s*--> 21 | |(^|\s)\} 22 | ) 23 | injections 24 | 25 | text.html.go - (meta.embedded.html.go | comment) 26 | 27 | patterns 28 | 29 | 30 | begin 31 | (^\s*)?(?={{) 32 | beginCaptures 33 | 34 | 1 35 | 36 | name 37 | punctuation.whitespace.embedded.leading.html 38 | 39 | 40 | contentName 41 | meta.embedded.html.go 42 | end 43 | (?!\G)(\s*\n)? 44 | endCaptures 45 | 46 | 1 47 | 48 | name 49 | punctuation.whitespace.embedded.trailing.html 50 | 51 | 52 | patterns 53 | 54 | 55 | begin 56 | {{ 57 | beginCaptures 58 | 59 | 0 60 | 61 | name 62 | punctuation.section.embedded.begin.html.go 63 | 64 | 65 | contentName 66 | source.html.go 67 | end 68 | }} 69 | endCaptures 70 | 71 | 0 72 | 73 | name 74 | punctuation.section.embedded.end.html.go 75 | 76 | 77 | patterns 78 | 79 | 80 | include 81 | #keywords 82 | 83 | 84 | include 85 | #constants 86 | 87 | 88 | include 89 | #variables 90 | 91 | 92 | include 93 | #methods 94 | 95 | 96 | include 97 | #calls 98 | 99 | 100 | include 101 | #strings 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | keyEquivalent 111 | ^~G 112 | name 113 | HTML (Go) 114 | patterns 115 | 116 | 117 | include 118 | text.html.basic 119 | 120 | 121 | repository 122 | 123 | calls 124 | 125 | captures 126 | 127 | 1 128 | 129 | name 130 | entity.name.function.html.go 131 | 132 | 133 | match 134 | (?<={{)\s*([\w\.]+)\b 135 | 136 | constants 137 | 138 | match 139 | \b(?:if|else|end|range|template|with)\b 140 | name 141 | keyword.control.html.go 142 | 143 | keywords 144 | 145 | match 146 | \b(?:true|false)\b 147 | name 148 | constant.language.html.go 149 | 150 | methods 151 | 152 | match 153 | \.[\w\.]+\b 154 | name 155 | support.function.any-method.html.go 156 | 157 | strings 158 | 159 | begin 160 | " 161 | beginCaptures 162 | 163 | 0 164 | 165 | name 166 | punctuation.definition.string.begin.html.go 167 | 168 | 169 | end 170 | (?<!\\)(?:\\\\)*\K" 171 | endCaptures 172 | 173 | 0 174 | 175 | name 176 | punctuation.definition.string.end.html.go 177 | 178 | 179 | name 180 | string.quoted.double.html.go 181 | 182 | variables 183 | 184 | match 185 | \$[\w\.]+\b 186 | name 187 | variable.other.predefined.html.go 188 | 189 | 190 | scopeName 191 | text.html.go 192 | uuid 193 | 76127A52-A229-4977-9885-E15CCF14948E 194 | 195 | 196 | -------------------------------------------------------------------------------- /Syntaxes/bugs.go: -------------------------------------------------------------------------------- 1 | package _αβx9 2 | 3 | // https://github.com/syscrusher/golang.tmbundle/issues/36#issuecomment-250866224 4 | func OkayReturn(x int) (string, error) { 5 | return "", nil 6 | } 7 | 8 | func BrokenNewlineReturn(name string) (string, 9 | error) { 10 | return "", 11 | nil 12 | } 13 | 14 | // https://github.com/syscrusher/golang.tmbundle/issues/36#issuecomment-250847018 15 | type x struct{} 16 | 17 | func (xx *x) OkayParam(a int) { 18 | return 19 | } 20 | 21 | func (xx *x) BrokenParenthesesParam(a func()) { 22 | return 23 | } 24 | 25 | func BrokenParenthesesParam2(a func()) { 26 | return 27 | } 28 | 29 | func (xx *x) OkayBracketParam(a interface{}) { 30 | return 31 | } 32 | 33 | func (xx *x) BrokenBracketParam(a struct{}) { 34 | return 35 | } 36 | 37 | func BrokenBracketParam2(a struct{}) { 38 | return 39 | } 40 | 41 | // https://github.com/syscrusher/golang.tmbundle/issues/36#issuecomment-260472685 42 | func typeVarsOkay() { 43 | var typeVars []int 44 | typeVars = append(typeVars, 1) 45 | } 46 | 47 | func typeVarsBroken() { 48 | var typeVars []int 49 | v := struct{ a int }{1} 50 | typeVars = append(typeVars, v.a) 51 | } 52 | -------------------------------------------------------------------------------- /info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | contactEmailRot13 6 | flfpehfure@hfref.abercyl.tvguho.pbz 7 | contactName 8 | syscrusher 9 | description 10 | Support for the <a href="http://golang.org">Go programming language</a>. 11 | mainMenu 12 | 13 | excludedItems 14 | 15 | 214A69FB-0168-465E-AB51-D8C6C46BCF61 16 | 17 | items 18 | 19 | 0B3C3EB0-9F51-4997-A87D-ECA507D8E31E 20 | 0F6A8710-54FC-48F5-9D02-D093DA001D17 21 | 73628139-0077-4F09-9B72-77546D7C2D2D 22 | B455A84C-0F20-494A-A3CC-49A89434DAB4 23 | ------------------------------------ 24 | D3CD6B51-3A7E-4356-85F4-B76B8336BEF2 25 | 7BCFCFC8-9152-4638-8436-E17B0C754C8D 26 | A04DD936-EEB1-484E-BF47-98BD6709D00C 27 | ------------------------------------ 28 | B0271A46-F6EF-4D2F-95A6-EC067E69155C 29 | 5509FB1E-C780-44ED-8BCF-4300ABC30C32 30 | 7E52594B-80CA-4EDD-B2B8-C54EB3844E95 31 | B09B40EA-FF74-425E-BE7F-A892077CC1F8 32 | 0E76DBD3-03DD-4184-8EED-A3E4F790B88D 33 | 72CC95BA-C5CA-4D39-A7E6-9533B33B9979 34 | ------------------------------------ 35 | C64599DA-E362-4411-9782-58A9C7F1B05A 36 | 88695E43-E330-4A5A-9492-C604DBD10A27 37 | F3EDE714-207E-4E99-9542-DFAC245C5E44 38 | 4BE04FFA-DF1F-4A48-BAF6-6711544ECAC9 39 | 25CE5652-3DF2-478F-820B-965F6F7F57A4 40 | C2D3D065-3434-4AC0-BB50-5D8676052D1F 41 | ------------------------------------ 42 | 98F0F28C-3B03-4792-AF44-24E2C4327EED 43 | 44 | submenus 45 | 46 | 25CE5652-3DF2-478F-820B-965F6F7F57A4 47 | 48 | items 49 | 50 | AF797914-E5F7-4F2B-866B-852889C6A925 51 | DE6B5489-7140-4954-AA78-6C4014525D38 52 | 26577C1F-0975-4A8F-BB89-375B0908FCA2 53 | EA490E02-1982-4F35-BBE5-D0B3DBCF148C 54 | C4732003-866C-466B-B72A-5FB209F46671 55 | ------------------------------------ 56 | D58425E7-F6E5-4249-8C57-277C4E38A5F4 57 | 7DA0072A-BF35-413B-B4D9-B5C2B4D20FF2 58 | 8C557B1F-C1C5-4FC3-830E-9D51DE6CFA5A 59 | ------------------------------------ 60 | 8C0BE817-6C6E-4927-85E5-9DA3FB8A7000 61 | 62 | name 63 | Control Flow 64 | 65 | 4BE04FFA-DF1F-4A48-BAF6-6711544ECAC9 66 | 67 | items 68 | 69 | FAE480BF-DF92-4B4F-8982-AB61CD05AD64 70 | 56603467-E883-4DB7-9562-62B841DC07CF 71 | 8FC95B21-86DE-4E94-889E-FE1472F1E25F 72 | DCF037CD-EF51-41BA-A29B-3184FB48685F 73 | 74 | name 75 | Initialization 76 | 77 | 88695E43-E330-4A5A-9492-C604DBD10A27 78 | 79 | items 80 | 81 | 9E325583-D146-41A4-BA94-0B5BF91DEBF8 82 | F4CA0BAC-E987-4154-BCBA-35B2668D514D 83 | E3553899-14C9-4B7E-ABF5-A1C14A33808C 84 | 7B2D69FC-DFEA-4548-91B7-4A698E63F22D 85 | E86778CD-D0DE-4E2E-AB13-740FA3E79814 86 | 113FC085-6E3C-432A-A2F1-D8BD54B8B49E 87 | E9B44CC5-B004-4793-B125-7E429FDCCE32 88 | 65FCDB2E-8AD1-4FF4-8E0E-DD4511A461F5 89 | D8CF6ACF-85BB-4AAD-BFDE-DFD9D075FCF2 90 | 0DF6CCE2-56DF-43EF-8EEE-BDFFEC38C244 91 | 92 | name 93 | Declaration 94 | 95 | C2D3D065-3434-4AC0-BB50-5D8676052D1F 96 | 97 | items 98 | 99 | 6B01E886-4CFA-476E-AE01-EFF406116978 100 | 92CF0E27-7ED9-4F9B-8061-DD2B38D22893 101 | 18A04BC9-D37A-46B9-8C92-4E8D287A46E4 102 | 54394BD4-1FFE-440F-9D3D-2D44F3B1BCC6 103 | ------------------------------------ 104 | 0FC09B94-D4C1-4C21-8076-EE7075174926 105 | 0E515A1F-B6F7-4473-B4C6-D6485E7CD133 106 | 4B3F378E-D9E8-4CCB-B537-96099B406511 107 | ------------------------------------ 108 | F5E717F6-A08B-4766-B1D5-0E43C796FDE1 109 | 6FCDC940-B46E-44E0-84F4-F2296EB17106 110 | 12AC27D2-4B5D-467D-AA52-1C8AACF753E7 111 | 3AC6807B-E0F6-4D68-90E9-A19A0F5F0176 112 | 113 | name 114 | Idioms 115 | 116 | C64599DA-E362-4411-9782-58A9C7F1B05A 117 | 118 | items 119 | 120 | CFE21C25-71DE-48A9-8FE6-2A40D8DF16EF 121 | 2DFA9510-6F88-4BC6-A409-DA4075DEA8FF 122 | 5E6327B4-8BD5-4079-8B25-D8D3EF9E89FB 123 | C6F66AFB-B50B-45AF-B2B2-819CC3464E56 124 | 125 | name 126 | Organization 127 | 128 | F3EDE714-207E-4E99-9542-DFAC245C5E44 129 | 130 | items 131 | 132 | E5E46A13-E5D3-49A3-9BFF-082A9DC69C08 133 | 96C65CC5-19C3-4B73-A66B-F9C80B98DE54 134 | CC5D7F66-6BBC-4D9C-BC32-D569238523EB 135 | 22E438EE-F254-4FB3-B05E-BA59387E3F6F 136 | 95F0EB07-61D5-4E0C-B610-BFD4A802A5C3 137 | C71F1625-B79B-463B-961D-D2071BF21821 138 | D6C5D7C0-06B6-4080-8E2B-8C646CADDE8C 139 | 140 | name 141 | Types 142 | 143 | 144 | 145 | name 146 | Go 147 | ordering 148 | 149 | 33100200-8916-4F78-8522-4362628C6889 150 | 05400837-EE8F-44D1-A636-3EEB0E82FFF5 151 | 160118A4-208D-4422-AFF0-0C21B5B78AAF 152 | 0B3C3EB0-9F51-4997-A87D-ECA507D8E31E 153 | 20810F68-79E2-4D36-B222-6374BDEAB7B9 154 | 0F6A8710-54FC-48F5-9D02-D093DA001D17 155 | 73628139-0077-4F09-9B72-77546D7C2D2D 156 | B0271A46-F6EF-4D2F-95A6-EC067E69155C 157 | 7BCFCFC8-9152-4638-8436-E17B0C754C8D 158 | CFE21C25-71DE-48A9-8FE6-2A40D8DF16EF 159 | 2DFA9510-6F88-4BC6-A409-DA4075DEA8FF 160 | 5E6327B4-8BD5-4079-8B25-D8D3EF9E89FB 161 | 9E325583-D146-41A4-BA94-0B5BF91DEBF8 162 | F4CA0BAC-E987-4154-BCBA-35B2668D514D 163 | E3553899-14C9-4B7E-ABF5-A1C14A33808C 164 | 7B2D69FC-DFEA-4548-91B7-4A698E63F22D 165 | E86778CD-D0DE-4E2E-AB13-740FA3E79814 166 | 113FC085-6E3C-432A-A2F1-D8BD54B8B49E 167 | E9B44CC5-B004-4793-B125-7E429FDCCE32 168 | 65FCDB2E-8AD1-4FF4-8E0E-DD4511A461F5 169 | D8CF6ACF-85BB-4AAD-BFDE-DFD9D075FCF2 170 | 0DF6CCE2-56DF-43EF-8EEE-BDFFEC38C244 171 | E5E46A13-E5D3-49A3-9BFF-082A9DC69C08 172 | 96C65CC5-19C3-4B73-A66B-F9C80B98DE54 173 | CC5D7F66-6BBC-4D9C-BC32-D569238523EB 174 | 22E438EE-F254-4FB3-B05E-BA59387E3F6F 175 | 95F0EB07-61D5-4E0C-B610-BFD4A802A5C3 176 | C71F1625-B79B-463B-961D-D2071BF21821 177 | D6C5D7C0-06B6-4080-8E2B-8C646CADDE8C 178 | FAE480BF-DF92-4B4F-8982-AB61CD05AD64 179 | 56603467-E883-4DB7-9562-62B841DC07CF 180 | 8FC95B21-86DE-4E94-889E-FE1472F1E25F 181 | DCF037CD-EF51-41BA-A29B-3184FB48685F 182 | AF797914-E5F7-4F2B-866B-852889C6A925 183 | DE6B5489-7140-4954-AA78-6C4014525D38 184 | 26577C1F-0975-4A8F-BB89-375B0908FCA2 185 | EA490E02-1982-4F35-BBE5-D0B3DBCF148C 186 | C4732003-866C-466B-B72A-5FB209F46671 187 | D58425E7-F6E5-4249-8C57-277C4E38A5F4 188 | 7DA0072A-BF35-413B-B4D9-B5C2B4D20FF2 189 | 8C557B1F-C1C5-4FC3-830E-9D51DE6CFA5A 190 | 6B01E886-4CFA-476E-AE01-EFF406116978 191 | 92CF0E27-7ED9-4F9B-8061-DD2B38D22893 192 | 18A04BC9-D37A-46B9-8C92-4E8D287A46E4 193 | 54394BD4-1FFE-440F-9D3D-2D44F3B1BCC6 194 | 0FC09B94-D4C1-4C21-8076-EE7075174926 195 | 0E515A1F-B6F7-4473-B4C6-D6485E7CD133 196 | 4B3F378E-D9E8-4CCB-B537-96099B406511 197 | 214A69FB-0168-465E-AB51-D8C6C46BCF61 198 | FE908865-7729-4926-9FAC-2D54895BEA48 199 | 200 | uuid 201 | 9A94FED7-9430-410F-9C6A-5B9D48A89180 202 | 203 | 204 | --------------------------------------------------------------------------------