kana/vim-smartpunc — Issue #13: Reconsider "syntax" matching algorithm
Author: kana
Created: 2012-02-18 06:50:28+00:00
State: open

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.