Reconsider "syntax" matching algorithm #13

Open
kana opened this Issue Feb 18, 2012 · 0 comments

Projects

None yet

1 participant

@kana
Owner
kana commented Feb 18, 2012

For example, the default syntax file for lisp:

  • Defines lispString for string constants, then
  • Links lispString to String, and
  • String is liked to Constant by default.

Therefore:

  • synIDattr(id, 'name') returns 'lispString'.
  • synIDattr(synIDtrans(id), 'name') returns 'Constant'.
  • And there is no simple way to detect whether a character is highlighted as String or not.

Currently synIDtrans()ed values are used to match "syntax" of rules. This
means that only Constant is a valid value for "syntax".
But Constant implies String, Number and other constants. If user wants to define rules only for String, such rules will never be used with the current behavior.

There are 4 options for the problem:

  • Use "wide" syntax names like Constant.
    • Merits:
      • No cost to implement -- this is the current behavior.
      • Easy to define generic rules on specific syntax items.
    • Demerits:
      • Not possible to define pinpoint rules on "detailed" syntax items like lispString.
  • Use "detailed" syntax names like lispString.
    • Merits:
      • Easy to implement -- just remove the use of synIDtrans().
      • Possible to define pinpoint rules on "detailed" syntax items like lispString.
    • Demerits:
      • Hard to define generic rules on specific syntax items.
  • Use both "wide" and "detailed" syntax names.
    • Merits:
      • Easy to define generic rules on specific syntax items.
      • Possible to define pinpoint rules on "detailed" syntax items like lispString.
    • Demerits:
      • Somewhat bad performance
        -- though it might be acceptable.
  • Use all, "wide" and "middle" and "detailed", syntax names.
    • Merits:
      • Maximum flexibility to define rules on specific syntax items.
    • Demeris:
      • Very bad performance
        -- the only way to get "middle" syntax names is to parse result of :highlight.

Let's reconsider which is the best way to deal with "syntax" matching.
Consider also actual usage and other possibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment