Coder Social home page Coder Social logo

go-tmbundle's Introduction

(a TextMate 2 language bundle) Version 2.0.1

Installation

The easiest way to install this bundle is to let TextMate 2 do the work for you: create a new .go file and open it in TextMate. The application will then suggest the Go language format and will download and install the bundle for you.

If you’d rather do things manually, or if you want to make changes to the repository, then in a Terminal window do:

mkdir ~/Library/Application\ Support/Avian/Bundles
cd ~/Library/Application\ Support/Avian/Bundles
git clone git://github.com/AlanQuatermain/go-tmbundle.git Go.tmbundle

Features

The bundle here implements a language syntax, some snippets, and some compile/format/documentation commands for the Go language (golang.org/). Much of the current infrastructure was created by Martin Kühl (github.com/mkhl), who is a significantly more seasoned TextMate bundle developer than I, and to whom I am eternally grateful.

Support for Go 1.0 was provided by Jeremy Whitlock (github.com/whitlockjc) and Michael Sheets (github.com/infininight), with additional code and fixes from Sylvain Defresne (github.com/sdefresne), liuyork (github.com/liuyork), and Alexey Palazhchenko (github.com/AlekSi).

Snippets

Simple Statements

Cmd-i

iota

,

A pair (‘first, second’), suitable for declaring result variables from a multi-return-value function or a map range loop.

<

Send/receive through a channel. Provides tab stops for the value and the channel name.

def

A default clause within a switch.

in

An empty interface type (i.e. matches anything).

imp

An import statement with optional alternative name.

imps

A multiple-import statement.

pkg

A package declaration including an optional comment block for packages other than ‘main’.

ret

A return statement with optional return value.

Initializers and Declarations

:

A short-form variable initializer (i.e. ‘name := value’).

[]

A slice variable type; expands to ‘[]type’, so is usable inside other snippets.

ch

A channel type.

con

A single constant declaration.

cons

A multiple constant declaration block.

fun

A function type definition statement.

int

An interface definition with a single method.

mk

A make statement (used for creating & initializing channels, maps, etc.).

map

A map variable type; expands to ‘map[keytype]valuetype’.

new

A new statement (used to create & initialize structure types).

st

A struct definition with a single member.

type

A type declaration, with name and variable type as tab-stops.

types

A block with multiple type declarations.

var

Declare a variable with an optional initial value (long form, i.e. ‘var x int = 10’).

vars

A block of long-form variable declarations.

Functions

de

A deferred goroutine call (defines the function inline).

func

A plain (global) function declaration, with tab stops for name, parameters, and a single optional result.

funcv

A plain (global) function declaration, with tab stops for name, parameters, and multiple results.

go

An immediate goroutine call (defines the function inline).

init

A template for a module’s +init()+ function, with a tab stop at its body.

main

A template for a +main()+ function with a tab stop at its body.

meth

Declares a function on a particular type, with additional tab stops for receiver name and type and a single optional result.

methv

Declares a function on a particular type, with additional tab stops for receiver name and type and multiple results.

Control Statements

case

A case clause, within a switch or select.

for

A for loop.

fori

A for loop with an index (similar to C for loops).

forr

A for loop iterating over a collection’s full range.

if

An if statement, properly formatted (Go requires the use of {} on ifs, unlike C; this throws me sometimes).

sel

A select statement, for looping over channel conditions.

sw

A switch statement with an optional expression.

Commands

Cmd-K

Build the current package or executable.

Cmd-R

Compile and run the current file.

Cmd-Opt-T

Launch the unittests for the current package using “go test”.

Ctrl-Shift-H

Reformat the document according to the Go style guidelines.

Ctrl-H

Show the Go HTML documentation for the currently-selected symbol.

<ESC>

Complete the symbol under the cursor.

Thanks

Thanks be to lasersox and Infininight over at the #textmate room on 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. 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.

Contact Information

You can contact me through github, or you can ping me on Twitter or alpha.app.net as ‘alanQuatermain’.

Happy coding :)

go-tmbundle's People

Contributors

alanquatermain avatar aleksi avatar chrisseaton avatar dhowden avatar drnic avatar guncha avatar infininight avatar mkhl avatar nicholasklick avatar okcpt avatar puchupala avatar robsonpeixoto avatar rsesek avatar schmurfy avatar sdefresne avatar sorbits avatar tassolee avatar whitlockjc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-tmbundle's Issues

`Can't find "gocode" on PATH` displayed when I press esc in a .go file

When I press esc in a .go file, I get:

Can't find “gocode” on PATH.

The current PATH is:

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/X11/bin
/usr/local/sbin
/Users/daryls/programming/golang/go/bin

Please add the directory containing “gocode” to PATH in TextMate's
Shell Variables preferences.

Alternatively, the PATH can be retrieved from Terminal but this
requires a relaunch:

Set PATH and Relaunch.

Indentation

I get an indentation error when pressing return after the last "}" when writing a function.

Keep up the good work!

Command + R doesn't seem to do anything in Textmate 1

Not sure what I'm missing. Bundle seems to be installed correctly. Syntax highlighting works. Made sure that /user/local/go/bin is in the path. However Command+R doesn't make window pop up. Nothing happens. Any clue what might be the problem?

Indentation in TM2 differs from go fmt

go fmt uses tabs, and ctrl+shift+h uses spaces. I opened gomate.rb and found this:

    if ENV['TM_SOFT_TABS'] && ENV['TM_SOFT_TABS'] == 'YES'
      args.push('-tabs=true')
    else
      args.push('-tabs=false')
    end

Isn't the logic reversed here?

missing file ?

/Users/user/Library/Application Support/TextMate/Bundles/go.tmbundle/Support/goerrs.rb:3:in `require': no such file to load -- /Applications/TextMate.app/Contents/SharedSupport/Support/lib/Build

I don't have a Build.rb in this directory.. are there any dependencies to other bundles?

Support goimports

It would be nice to be able to use goimports in place of gofmt. Maybe with an environment variable?

Support TextMate 2

It'd be best to allow the bundle to be selected/installed from the Bundle preference pane of TM2. That would make installation even easier.

Use goimports on save if available

Since goimports is a superset of gofmt functionality, (perhaps optionally) using it instead of gofmt on save not only formats code, but handles imports as well.

Syntax highlighting problem

var (
	factories      = make(map[string]func() (Collector, error))
	collectorState = make(map[string]*bool)
)

func registerCollector(collector string, isDefaultEnabled bool, factory func() (Collector, error)) {
  // ...
}

Note that everything is black after collectorState variables.

jumping to error line is broken

When compiling (⌘K), if there's an error in compiler output, clicking on it's link jumps to the file in question, but not the offending line. It happens because the following TextMate link is generated:

txmt://open?line=&url=file:///Users/gunca/Desktop/test.go

TextMate Version 1.5.10 (1623)
Bundle version: tip

Gocode completion stopped working

Since I've upgraded to OSX Mavericks, the gocode completion stopped working.
Gocode is installed, TextMate has both TM_GOCODE and PATH configured to reach the gocode binary.

I also have SublimeText 2 installed, it's gocode completion works fine.

Is there any way to debug this, console output, text mate bundle output?

strings cannot contain comments

It appears that strings, and I guess runes too, but they are only single characters, do not create custom syntax blocks as the language specifies. E.g. this should not be a comment:

"https://example.com"

Function head across lines is not recognized as a function

The following examples will illustrate the issue because github uses your go-tmbundle for syntax highlighting:

One line function head:

func OneLiner(w io.Writer, r io.Reader) {}

Across lines function head:

func OneLiner(
  w io.Writer, 
  r io.Reader,
) {}

error @ build or run or compile

i am not sure if this is the best place to raise this....i get this error when i try to compile with a golang bundle. i hoping somebody can help me resolve this issue. prog compiles and works fine using command line -

:29:in require': no such file to load -- /Applications/TextMate.app/Contents/SharedSupport/Support/lib/Builder (LoadError) from :29:inrequire' from /Users/ns/Library/Application Support/TextMate/Bundles/Go.tmbundle/Support/goerrs.rb:3:in ' from :29:inrequire' from :29:in require' from /Users/ns/Library/Application Support/TextMate/Bundles/Go.tmbundle/Support/gomate.rb:5:in' from :29:in require' from :29:inrequire' from /tmp/temp_textmate.KoOLaG:3:in `'

gofmt -tabwidth not supported in go1.3

When formatting a Go file in TextMate with this bundle, I get:

flag provided but not defined: -tabwidth
usage: gofmt [flags] [path ...]
-cpuprofile="": write cpu profile to this file
-d=false: display diffs instead of rewriting files
-e=false: report all errors (not just the first 10 on different lines)
-l=false: list files whose formatting differs from gofmt's
-r="": rewrite rule (e.g., 'a[b:len(a)] -> a[b:]')
-s=false: simplify code
-w=false: write result to (source) file instead of stdout

This seems to be caused by this line:

args.push("-tabwidth=#{ENV['TM_TAB_SIZE']}")

I didn't see this error with go1.2.

$ go version
go version go1.3 darwin/amd64

Double-click selection is wonky

Selection behavior of double-clicking in Go code is weird and annoying in some contexts:

  • Anywhere in a function parameter list, it selects the entire parameter list (to just inside the parens.)
  • In an initializing assignment, like foo := bar(), double-clicking foo also selects the space after it.
  • In a top-level variable declaration, like var foo = 0, double-clicking foo also selects the space before it.

This must be due to some subtlety of the language-grammar file, but I don't know nearly enough about those to be able to diagnose the problem.

Couldn't find g

Hi,
I tried using the bundle to give go a try but I cannot make it works. Go is installed by homebrew and I have all the go* binaries in my path but when I hit Apple+R all I get is an error "Couldn't find g" with all the locations in the search PATH printed below.

I tried to find where the error occured in the code without luck (the path followed is not easy to find with one executable calling another and another including another one xD).

Any idea what could go wrong ?

Compiler error not linkified if message contains a ":"

The following Go compiler error doesn't get turned into a source code link:

rest.go:255: syntax error: unexpected name, expecting semicolon or newline or }

The problem is that Go::link_errs sees that there are three : characters on the line and tries to interpret what's between the second and third :s as a column number, which doesn't work.

link_errs should probably not be counting colons like this. Instead it should use a single regex that optionally recognizes a column number if it's present.

Auto-complete (Escape) fails with: Can't find “gocode” on PATH

The current PATH is:

/usr/bin
/bin
/usr/sbin
/sbin
Please add the directory containing “gocode” to PATH in TextMate's Shell Variables preferences.

Alternatively, the PATH can be retrieved from Terminal but this requires a relaunch: 

Do I need to set up a PATH (not mentioned in README) or is it a bug in the bundle? I installed go via brew.

Won't Run if the .go File is in a Folder with a Space in the Name

I'm not sure what stage it fails at, but it treats the part of the filename before the space as the entire filename.
For instance, if the .go file resides in
/Users/kelsey/One Two/
, the Run command fails with
: fatal error: open /Users/kelsey/One:: No such file or directory

Add a "Build" command

The "Compile" command (Cmd-K) is only useful for single-file executables. When building a package, or even a multi-file executable, it'll fail with undefined-symbol errors because it only tries to compile the one source file being edited.

A "Build" command that runs "go build" in the current file's directory would be more useful. The sdefresne fork of this repo already has it; hopefully it's easy to move over.

Rewrites 2-spaces as tabs on save

My global Textmate 2 preferences are tabSize = 2, softTabs = true. This bundle rewrites the 2-spaces as tabs on save. For troubleshooting, disabling Go > Themes or Go > Language Grammars > Go stops the rewrites on save. Other language bundles function correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.