[Geany-Users] filetype, lexer, config file: using a new language

John Gabriele jgabriele at fastmail.fm
Sun May 22 01:11:11 UTC 2022

On Sat, May 21, 2022, at 7:21 PM, Lex Trotman wrote:
> On Sun, 22 May 2022 at 01:31, John Gabriele <jgabriele at fastmail.fm> wrote:
>> Hi all,
>> I'd like to use the [Hare](https://harelang.org/) programming language
>> with Geany. I see that the C syntax highlighting works ok so far (and
>> it appears that [Lexilla](https://github.com/ScintillaOrg/lexilla)
>> (which I understand Geany makes use of) supports C, C++, Java, and JS
>> all using the same lexer:
>> https://github.com/ScintillaOrg/lexilla/blob/master/lexers/LexCPP.cxx
>> Anyhow, when I open a .ha file (Hare source file) with Geany, I'd like
>> for it to just use the C syntax highlighting automatically, so I don't
>> have to manually select it each time. How can I get that to work?
> You also need to specify the filetype in `filetype_extensions.conf`

Ok. I opened that file (under Tools --> Configuration Files...). The file is
in my ~/.config/geany/ dir, and *every* line is commented out.
I uncommented line containing "[Extensions]", and then added one of
my own:


> and note the filetype name you use there and the filetype name used in
> the `filetype.XXX.conf` filename are case sensitive and must match
> exactly.

I'm not sure what you mean. I did this:

    cp /usr/share/geany/filedefs/filetypes.c ~/.config/geany/filedefs/filetypes.Hare.conf

I didn't edit anything in this file, but I see that it contains these

# default extension used when saving files

Is that something I need to change?

> Note that you can open `filetype_extension.conf` in the menu
> `Tools->Configuration Files` and it will open the one in your user
> config, or the system one if no user one yet, but always saves to your
> user config.
>> I'm on GNU/Linux, and I see that I've got a ~/.config/geany directory.
>> Looking at the manual, I don't understand the different axes of
>> filetype def files vs config files ...
>> I see that I have a /usr/share/geany/filedefs/filetypes.c file.
>> Do I copy that to my ~/.config/geany/filedefs dir? After that, what
>> do I change in that file?
> Correct target directory, but what you need is a "custom filetype"
> which can specify which lexer and/or existing parser to use, see
> https://www.geany.org/manual/current/index.html#custom-filetypes.
> There are examples of custom filetypes in the system filedefs
> directory, eg Scala.
>> Also, why do some of the files in /usr/share/geany/filedefs end in
>> .conf while others don't?
> Custom filetypes vs builtin filetypes.
> Cheers
> Lex

Thanks, Lex. I quit and restarted Geany, opened a .ha file, but it's
not syntax-highlighted. Though, I do see that under "Document -->
Set Filetype", there's a new checkbox there (under "None") that
says "Hare file", and it's checked!

Is syntax highlighting separate from filetype? How can I get it
to syntax highlight the .ha file (using the same syntax highlighting
as C gets, I presume).

-- John

More information about the Users mailing list