ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Nicola <nvitacolonna@gmail.com>
To: ntg-context@ntg.nl
Subject: Re: How to write readable source files?
Date: Sun, 30 May 2021 08:13:48 -0000 (UTC)	[thread overview]
Message-ID: <s8vhfs$13go$1@ciao.gmane.io> (raw)
In-Reply-To: <f5ae2c98-89b0-399a-bd6b-9b006006d7a6@xs4all.nl>

On 2021-05-29, Hans Hagen <j.hagen@xs4all.nl> wrote:
> so what does vim expect? isn't there some kind of common format for lexers?

The output I need is very simple:

    syn keyword Group1 <keyword1> <keyword2> ...
    syn keyword Group2 <keyword1> <keyword2> ...
    ...

where Group1, Group2, ... define arbitrary groups of keywords. For
instance, for MetaFun I currently have `mpDef` (MetaPost def macro),
`mpVardef` (MetaPost vardef), `mpPrimaryDef`, `mpSecondaryDef`,
`mpTertiaryDef`, `mpCommand`, `mpConstant`, `mpVariable`, `mpType`,
`mpNewInternal`, and a few others. An excerpt from the current syntax
file looks like this:

    ...
    " mp-base.mpiv
    syn keyword mpNumExp       graypart
    syn keyword mpType         graycolor greycolor
    syn keyword mpConstant     cyan magenta yellow
    " mp-butt.mpiv
    syn keyword mpDef          predefinedbutton some_button
    syn keyword mpConstant     context_butt
    " mp-char.mpiv
    syn keyword mpDef          flow_begin_chart flow_begin_sub_chart
    syn keyword mpDef          flow_chart_draw_comment flow_chart_draw_exit
    ...
    syn keyword mpVardef       flow_xy_on_grid flow_xy_right flow_xy_top
    syn keyword mpVardef       flow_y_on_grid
    syn keyword mpVariable     flow_arrowtip flow_chart_background_color
    syn keyword mpVariable     flow_chart_offset flow_comment_offset
    syn keyword mpVariable     flow_connection_arrow_size
    ...

This fine-grained classification allows for great flexibility when
defining syntax highlighting, because each group can have different
properties (and the user can customize that), although by default
several groups are highlighted in the same way (e.g., all macros have
the same highlighting by default).

Nicola

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2021-05-30  8:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-24  9:45 Jan U. Hasecke
2021-04-24 11:55 ` Henning Hraban Ramm
2021-04-24 13:25   ` Hans van der Meer
2021-04-24 13:45   ` juh
2021-04-24 19:25     ` Nicola
2021-04-25  7:13       ` juh
2021-04-25 12:12         ` Nicola
2021-04-25 12:24           ` Hans Hagen
2021-05-29 15:03             ` Nicola
2021-05-29 17:08               ` Hans Hagen
2021-05-29 18:29                 ` Nicola
2021-05-29 23:04                   ` Hans Hagen
2021-05-30  8:13                     ` Nicola [this message]
2021-04-24 12:12 ` luigi scarso
2021-04-24 15:17 ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='s8vhfs$13go$1@ciao.gmane.io' \
    --to=nvitacolonna@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).