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

查看:352
本文介绍了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!

此外,默认情况下,在Geany的Document> Set Filetype中列出并选择了Kivy文件类型,所以我必须在这里做些事情!

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天全站免登陆