I am trying to make syntax hightlighting and building options work for Geany, any advice?
-
For my fellow Windows programmers, there is a silly trick to getting this to work: `filetypes.go.conf` must actually be named `filetypes.Go.conf` – Adam Crossland Jul 25 '11 at 14:06
5 Answers
I just noticed this page: http://go-lang.cat-v.org/text-editors/geany/
Seems like they've got everything you need right there.

- 81
- 1
- 1
-
1Welcome to Stack Overflow! While this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Bill the Lizard Apr 06 '12 at 12:19
Here is the Geany formatting Instructions posted by Steve Horsley to golang-nuts:
In Geany, goto Tools->Configuration Files->filetype_extensions.conf and add in the following new heading:
Go=*.go;
Copy the C definition filetypes.c to filedefs/filetypes.Go.conf:
cp /usr/share/geany/filetypes.c ~/.config/geany/filedefs/filetypes.Go.conf
Edit filetypes.Go.conf and change the setting and keywords sections to this:
[settings] # default extension used when saving files extension=go lexer_filetype=C [keywords] # all items must be in one line primary=break case chan const continue default defer else fallthrough for func go goto if import interface map package range return select struct switch type var secondary=byte int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float32 float64 complex64 complex128 uintptr string

- 1,757
- 2
- 20
- 23
Look in $GOROOT/misc and http://go-lang.cat-v.org/text-editors/ for syntax files from other editors to get an idea.
Barring that, start with C or C++ and add/substract things like go
, <-
, func
, etc.

- 9,389
- 4
- 36
- 28
-
I started with C and nothing works :( I've created a ~/.config/geany/filetypes.go based on the C one provided and get no hightlighting at all. – Matt Joiner Nov 26 '10 at 02:56
I made a Python script that automates the directions in the link provided by Jaybill McCarthy.
import shutil, re, os
HOME = os.environ['HOME']
shutil.copy('/usr/share/geany/filetype_extensions.conf', HOME +'/.config/geany/')
with open(HOME + '/.config/geany/filetype_extensions.conf', 'r') as f:
fileData = f.read()
fileData = re.sub(r'Haskell=.*;', r'Go=*.go;\nHaskell=*.hs;*.lhs;', fileData)
fileData = re.compile('(\[Groups\][^\[]Programming=.*?$)', re.DOTALL|re.MULTILINE).sub(r'\1Go;', fileData)
with open(HOME + '/.config/geany/filetype_extensions.conf', 'w') as f:
f.write(fileData)
textSettings = """[settings]
extension=go
lexer_filetype=C
comment_single=//
comment_open=/*
comment_close=*/
comment_use_indent=true
"""
textKeywords = """[keywords]
primary=break case chan const continue default defer else fallthrough for func go goto if import interface map package range return select struct switch type var
secondary=byte int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float32 float64 complex64 complex128 uintptr string"""
shutil.copy('/usr/share/geany/filetypes.c', HOME + '/.config/geany/filedefs/filetypes.Go.conf')
with open(HOME + '/.config/geany/filedefs/filetypes.Go.conf', 'r') as f:
fileData = f.read()
fileData = re.compile(r'\[settings\].*?^\[', re.DOTALL|re.MULTILINE).sub('%s\n\n[' %textSettings, fileData)
fileData = re.compile(r'\[keywords\].*?^\[', re.DOTALL|re.MULTILINE).sub('%s\n\n[' %textKeywords, fileData)
with open(HOME + '/.config/geany/filedefs/filetypes.Go.conf', 'w') as f:
f.write(fileData)
print "Complete!"
I'm not sure if this means I am lazy, or the other way around... o.O.

- 6,038
- 3
- 23
- 27
Have you defined the Go filetype in ~/.config/geany/filetype_extensions.conf ?
[Extensions]
...
Go=*.go
...
if the conf file doesn't yet exist, copy it from /usr/share/geany and add that line under 'Extensions' (or look for it under Tools > Configuration Files).

- 2,711
- 19
- 8