Adam Gaskins
Adam Gaskins

Reputation: 399

Custom syntax highlighting in Geany

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.

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

Kivy=*.kv;

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

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!

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

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?

Thank you!

Upvotes: 12

Views: 19119

Answers (2)

Leachim
Leachim

Reputation: 1

There are three important things to obey:

  • the configuration file should be placed in "~/.config/geany/filedefs"

  • the configuration file must have the extension ".conf" - otherwise it won't show up at all (the files in "/usr/share/geany/filesdefs", where I copied my base file from, do not have a ".conf" extension!)

  • you must set the "lexer_filetype" to an existing (presumably builtin) configuration; e.g. "lexer_filetype=Python"

Upvotes: 0

jasso
jasso

Reputation: 13966

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.

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

Upvotes: 9

Related Questions