Geany 中的自定义语法高亮显示 [英] Custom syntax highlighting in Geany

查看:39
本文介绍了Geany 中的自定义语法高亮显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Geany 编辑器中为 Kivy '.kv' 文件创建自定义语法突出显示.尽管特定的文件类型似乎与我遇到的问题无关,但因为我为使语法突出显示适用于自定义文件类型所做的任何努力都会导致完全未突出显示的文件.我相信我已经完成了这方面的功课,但似乎没有任何效果.

I am trying to create custom syntax highlighting for Kivy '.kv' files in the Geany editor. Although the specific filetype seems irrelavant to the issue I'm having, as any efforts I make at getting syntax highlighting to work for a custom filetype results in a completely non-highlighted file. I believe I have done my homework on this, and nothing seems to work.

我已将以下内容添加到 ~/.config/geany/filetype_extensions.conf

I have added the following to ~/.config/geany/filetype_extensions.conf

Kivy=*.kv;

我在 ~/.config/geany/filedefs/中还有一个名为filetypes.Kivy.conf"的自定义类型定义文件.我尝试将此文件基于/usr/share/geany/中的几个库存类型定义文件,并且该文件从未在 Geany 中应用任何语法突出显示.现在,只是为了实验,我的 'filetypes.Kivy.conf' 文件看起来像这样:

I also have a custom type definition file named 'filetypes.Kivy.conf' in ~/.config/geany/filedefs/. I have tried basing this file off several of the stock type definition files in /usr/share/geany/ and the file never gets any syntax highlighting applied in Geany. Right now, just for experimentation's sake, my 'filetypes.Kivy.conf' file looks like this:

# For complete documentation of this file, please see Geany's main documentation
[settings]
# default extension used when saving files
extension=kv

# single comments, like # in this file
comment_single=#

[keywords]
# all items must be in one line
primary=size canvas
secondary=pos size

[indentation]
width=4
# 0 is spaces, 1 is tabs, 2 is tab & spaces
type=0

这非常松散地基于股票 XML 定义文件,但就像我说的那样,我已经尝试了许多其他股票文件.在许多情况下,我只将 'extension=' 值更改为 kv,但仍然没有应用突出显示,即使在 Geany 中转到 Document>Set Filetype 并选择几乎任何随机文件类型(除了我的自定义条目)都会产生某种结果在我的 .kv 文件中突出显示. 甚至在使用未修改的股票定义内容时也是如此,否则当在 Geany 中特别选择时,它可以在我的 .kv 文件上正常工作!

This is very loosly based on the stock XML definition file, but like I said I've tried many other stock files. In many cases I only changed the 'extension=' value to kv and still no highlighting was applied, even though going to Document>Set Filetype in Geany and choosing virtually any random filetype (besides my custom entry) would yeild some sort of highlighting within my .kv file. This is even the case when using the unmodified contents of a stock definition which otherwise works fine on my .kv file when specifically selected in Geany!

此外,Kivy 文件类型在 Document>Set Filetype within Geany 中默认列出和选择,所以我必须在这里做点什么!

Also, the Kivy filetype is listed and selected by default in Document>Set Filetype within Geany, so I must be doing something right here!

我意识到有人问过这个类似的问题,但解决方案似乎与我的情况无关,因为我已经尝试了这个网站和许多其他网站上的所有相关主题.我的 Geany 版本是 1.22,我正在运行 Arch Linux.这让我发疯 - 有什么建议吗?

I realize this similar question has been asked, but the solutions seem irrelavent to my case, as I've tried every related topic on this and many other sites. My Geany version is 1.22 and I'm running Arch Linux. This is driving me nuts - any suggestions?

谢谢!

推荐答案

在文件类型文件的 [settings] 部分设置 lexer_filetype= 属性.工作突出显示需要有一个词法分析器可用于突出显示 .kv 文件.

Set lexer_filetype= property in the [settings] section of your filetype file. Working highlighting requires that there is a lexer that could be used for highlighting the .kv-files.

有关详细信息,请参阅 http://www.geany.org/manual/#lexer-文件类型

For more info see http://www.geany.org/manual/#lexer-filetype

这篇关于Geany 中的自定义语法高亮显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆