Syntax highlighting and support for TextMate

534 views
Skip to first unread message

Rasmus Andersson

unread,
Nov 10, 2009, 9:59:46 PM11/10/09
to golang-nuts
I've created a TextMate[1] bundle for Go:

http://github.com/rsms/Go.tmbundle

[1] http://macromates.com/

Adam Langley

unread,
Nov 10, 2009, 10:10:42 PM11/10/09
to Rasmus Andersson, golang-nuts
On Tue, Nov 10, 2009 at 6:59 PM, Rasmus Andersson <ras...@notion.se> wrote:
> I've created a TextMate[1] bundle for Go:
>
> http://github.com/rsms/Go.tmbundle

Thanks. I'm not sure how TextMate works. Does one typically ship a
bundle in a 'misc' or 'contrib' directory?


AGL

Rasmus Andersson

unread,
Nov 10, 2009, 10:14:28 PM11/10/09
to golang-nuts
There is a central (but somewhat stale) official repository for
contributed bundles at http://svn.textmate.org/trunk/Bundles , but in
some cases the bundles are distributed as part of what it covers
(usually in a contrib dir).

>
> AGL

Adam Langley

unread,
Nov 10, 2009, 11:13:15 PM11/10/09
to Rasmus Andersson, golang-nuts
On Tue, Nov 10, 2009 at 7:14 PM, Rasmus Andersson <ras...@notion.se> wrote:
> There is a central (but somewhat stale) official repository for
> contributed bundles at http://svn.textmate.org/trunk/Bundles , but in
> some cases the bundles are distributed as part of what it covers
> (usually in a contrib dir).

Then we would welcome a patch to add this!

http://golang.org/doc/contribute.html

NB the copyright section at the end. For legal reasons we cannot
accept code without it.

Cheers

AGL

Tom Joseph

unread,
Nov 11, 2009, 4:31:28 AM11/11/09
to golang-nuts
Thanks!

One issue though - in the "Compile and Run Single File" command,
"uname -r" is not a reliable way to determine if the machine is
x86_64, since Snow Leopard usually has a 32-bit kernel on 64-bit Macs.
Here is my suggested modification of the relevant code:

if [ "$(arch -arch x86_64 /usr/bin/true)" == "" ]; then
N=6
export GOARCH=amd64
else
N=8
export GOARCH=386
fi

--Tom

On Nov 10, 9:59 pm, Rasmus Andersson <ras...@notion.se> wrote:
> I've created aTextMate[1] bundle for Go:

Louis St-Amour

unread,
Nov 11, 2009, 11:28:09 PM11/11/09
to golang-nuts
I've a suggestion also, having just seen http://golang.org/doc/effective_go.html
on gofmt

An easy command anyone can add. Click Bundle Editor > Edit Commands,
then under Go, click the plus button, and call this command "Format
File" (or whatever, but gofmt seems to only support full files).

Use the following settings:

Save: Nothing
Command(s): (the following three lines, of which only "gofmt" is
really required)
. "$TM_SUPPORT_PATH/lib/html.sh"
require_cmd gofmt
gofmt
Input: Entire Document (not Selection)
Output: Replace Document
Activation -- whatever, I'm undecided.

Close the window, and try it! :-)


Louis St-Amour.

Louis St-Amour

unread,
Nov 11, 2009, 11:34:02 PM11/11/09
to golang-nuts
Not sure if this is related to the Go.tmbundle, but I've just
discovered that gofmt assumes a tab width of 4 spaces, and obviously
expects tabs, not soft tabs. You can test it with the example given at
http://golang.org/doc/effective_go.html

type T struct {
name string; // name of the object
value int; // its value
}

becomes

type T struct {
name string; // name of the object
value int; // its value
}

Oh! Of course there are formatting options for gofmt, so feel free to
add them to the command somehow, though I can't imagine the community
as a whole wanting to deviate much from the default.

usage: gofmt [flags] [path ...]
-l=false: list files whose formatting differs from gofmt's
-w=false: write result to (source) file instead of stdout
-trace=false: print parse trace
-spaces=false: align with spaces instead of tabs
-tabwidth=8: tab width
-align=true: align columns
-comments=true: print comments


On Nov 11, 11:28 pm, Louis St-Amour <louisstam...@gmail.com> wrote:
> I've a suggestion also, having just seenhttp://golang.org/doc/effective_go.html

Louis St-Amour

unread,
Nov 11, 2009, 11:38:06 PM11/11/09
to golang-nuts
On Nov 11, 11:34 pm, Louis St-Amour <louisstam...@gmail.com> wrote:
> Not sure if this is related to the Go.tmbundle, but I've just
> discovered that gofmt assumes a tab width of 4 spaces, and obviously

Correction, it's 8 space tabs, as the usage note below indicates, not
4.

rod...@joldit.com

unread,
Jul 26, 2013, 5:59:28 PM7/26/13
to golan...@googlegroups.com, ras...@notion.se
Any update on this? Would be awesome to have a Go bundle by default in Texmate 1.
Reply all
Reply to author
Forward
0 new messages