我正在尝试使语法Hightlight和建筑选择适用于Geany,有什么建议吗?

有帮助吗?

解决方案

查看$ goroot/杂项和 http://go-lang.cat-v.org/text-editors/ 对于其他编辑器的语法文件,以获取一个想法。

除此之外,从c或c ++开始,然后添加/添加诸如 go, <-, func, , ETC。

其他提示

我只是注意到此页: http://go-lang.cat-v.org/text-editors/geany/

似乎他们在那里拥有您需要的一切。

这里是 史蒂夫·霍斯利(Steve Horsley)发布给golang-nuts的Geany格式说明:

  1. 在geany,goto tools-> configuration files-> filetype_extensions.conf中,添加以下新标题:

    Go=*.go;
    
  2. 将C定义FileTypes.c复制到fileedefs/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
    

您是否在〜/.config/geany/filetype_extensions.conf中定义了GO Filetype?

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

如果尚不存在conf文件,请从/usr/share/geany复制它,并在“扩展”下添加该行(或在工具>配置文件下查找它)。

我制作了一个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!"

我不确定这是否意味着我很懒惰,还是反过来……哦

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top