Highlighting ssyntax VS highlighting valid numbers

Issue #1 new
fallintothis
repo owner created an issue

Highlighting ssyntax characters is tough, especially when they're also valid characters within other symbols (controlled by the &iskeyword variable in Vim). Particular culprits are #. and #+. i.e., if we exclude 46 (ASCII code for #.) from &iskeyword, we get:

{{{ ; :set isk-=46 -.a ; == (- a) and highlights the #- and the #. as such -.1 ; == -0.1, but highlights like -.1 == (- 1) since the subtraction ; function (-) is a keyword, which takes highlighting priority over ; anything else -0.1 ; the good news: this still highlights like a number }}}

But if we add it:

{{{ ; :set isk+=46 -.a ; == (- a) doesn't highlight the #- because keywords (like the ; subtraction function) must occur as whole words, and #. is right next ; to #- here. -.1 ; == -0.1 highlights just fine -0.1 ; this still highlights like a number }}}

Since the numbers can be written with leading zeroes, the ssyntax seems more common, and I can't think of any other edge-cases, I decided to go with the first option here.

But #+ is a valid keyword character; unlike #\:, #\~, #., and #!, it's actually in existing function names. So, &iskeyword //needs// to have 43 (ASCII code for #+). But then

{{{ positive ; highlights just fine odd ; highlights just fine positive+odd ; only highlights the + as ssyntax and does not highlight ; positive or odd since "positive+odd" runs together as a single ; keyword }}}

There's not much to do about this. It should be fixed by using a better character for #+ (I can think of no reason to include #\& in &iskeyword once it becomes ssyntax): http://arclanguage.org/item?id=10098

It might also be solved by pulling off even more hacks, like special-casing #+, #-, and other characters that can appear in numbers into //syn-match//es instead of //syn-keyword//s, but this is very unappealing. If there are any Vim / regular expression wizards that can help, I'd appreciate it.