如何向 Geany 添加 Go 支持

发布于 2024-09-17 09:32:36 字数 41 浏览 4 评论 0原文

我正在尝试使语法突出显示和构建选项适用于 Geany,有什么建议吗?

I am trying to make syntax hightlighting and building options work for Geany, any advice?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

我喜欢麦丽素 2024-09-24 09:33:25

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

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.

清引 2024-09-24 09:33:18

您是否在 ~/.config/geany/filetype_extensions.conf 中定义了 Go 文件类型?

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

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

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).

夏夜暖风 2024-09-24 09:33:13

以下是 Steve Horsley 向 golang-nuts 发布的 Geany 格式说明:

  1. 在 Geany 中,转到“工具”->“配置文件”->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 并将设置和关键字部分更改为:

    <前><代码>[设置]
    # 保存文件时使用的默认扩展名
    扩展名=去
    词法分析器文件类型=C

    [关键词]
    # 所有项目必须在一行中
    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

Here is the Geany formatting Instructions posted by Steve Horsley to golang-nuts:

  1. In Geany, goto Tools->Configuration Files->filetype_extensions.conf and add in the following new heading:

    Go=*.go;
    
  2. Copy the C definition filetypes.c to filedefs/filetypes.Go.conf:

    cp /usr/share/geany/filetypes.c ~/.config/geany/filedefs/filetypes.Go.conf
    
  3. 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
    
小帐篷 2024-09-24 09:33:06

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

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

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.

微凉徒眸意 2024-09-24 09:33:00

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

看起来他们已经拥有你需要的一切。

I just noticed this page: http://go-lang.cat-v.org/text-editors/geany/

Seems like they've got everything you need right there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文