[Geany-Users] Override comment_single in custom filetypes.xres.conf

Lex Trotman elextr at xxxxx
Sun Aug 30 23:45:36 UTC 2020


On Sun, 30 Aug 2020 at 23:24, D.T. <ohnonot-github at posteo.de> wrote:
>
> Hello,
> I have been struggling with this for a couple of hours, mostly reading
> https://geany.org/manual/index.html#custom-filetypes to no avail, now
> it's time to ask for your help!
>
> I have a rather simplistic custom filetype for Xresources files:
>
>    [styling]
>    default=default
>    comment=comment
>    section=tag
>    key=attribute
>    assignment=operator
>    defval=value
>
>    [lexer_properties]
>    lexer.props.allow.initial.spaces=0
>
>    [settings]
>    extension=xres
>    mime_type=text/x-xres
>    lexer_filetype=Conf
>    wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234
>    56789#
>    comment_single=!
>
> It works well enough; the only aspect where it differs from the Conf
> filetype is that comments start with a '!', not with a '#'.
> This works well enough, but not with #include directives that are also
> valid Xresources syntax.
> How can I tell geany to see _only_ lines starting with '!' as comments?
> Currently it treats lines starting with '!' and '#' both as comments.

The Lexers that recognise syntactic elements are part of the Scintilla
editing widget Geany uses (and is a separate project from Geany).

Your line `lexer_filetype=Conf` selects the `Conf` syntax and the
lexer likely has `#` as comment hard coded, after all its not variable
in the Conf syntax.

So short of changing the code for the Conf lexer there is no way of
setting the comment character.

Currently Geany does not support any form of user defined lexers which
would need to use regular expressions or similar mechanisms.  This
keeps the code fast and light.

Cheers
Lex

>
> Additional bonus: customised syntax highlighting for #include
> directives. Example:
> #include </path/to/includes/X.xres>

And while you are modifying the lexer you can add the bonus. :)

>
> Thanks for a great lightweight IDE!
>
> o.
>
>
> _______________________________________________
> Users mailing list
> Users at lists.geany.org
> https://lists.geany.org/cgi-bin/mailman/listinfo/users


More information about the Users mailing list