繁体   English   中英

如何向Geany添加Go支持

[英]How to add Go support to Geany

我正在努力使语法高亮显示并为Geany构建选项,任何建议?

我刚刚注意到这个页面: http//go-lang.cat-v.org/text-editors/geany/

好像他们在那里得到了你需要的一切。

这是由史蒂夫霍斯利发布Geany格式说明golang-nuts:

  1. 在Geany中,转到Tools-> Configuration Files-> filetype_extensions.conf并添加以下新标题:

     Go=*.go; 
  2. 将C定义filetypes.c复制到filedefs / filetypes.Go.conf:

     cp /usr/share/geany/filetypes.c ~/.config/geany/filedefs/filetypes.Go.conf 
  3. 编辑filetypes.Go.conf并将设置和关键字部分更改为:

     [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 

查看$ GOROOT / misc和http://go-lang.cat-v.org/text-editors/,了解其他编辑的语法文件,以获得一个想法。

除此之外,从C或C ++开始,添加/减去go<-func等等。

我制作了一个Python脚本,可以自动化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!"

我不确定这是否意味着我很懒,或者反过来...... oO

你在〜/ .config / geany / filetype_extensions.conf中定义了Go文件类型吗?

[Extensions]
...
Go=*.go
...

如果conf文件尚不存在,请从/ usr / share / geany复制它,并在'Extensions'下添加该行(或在Tools> Configuration Files下查找)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM