For those who love code, there is nothing worse than looking at ugly code. My current syntax highlighting file scheme.vim
for the editor vim
on debian
does not seem to recognize some character literals which are perfectly legal (at least in guile
or indeed scm
). For example the character literal #\x0000
which refers to the hexadecimal unicode point 0x0000
is recognized as such and properly displayed, but if I use an octal representation #\000
or a name representation #\nul
, then vim
gives me this bright orange (I am guessing the intent is to highlight an error condition). Does anyone have a suggestion helping me to fix this?
This is a more polished version of what came out of the comments:
The existing syntax file scheme.vim
probably recognizes some names for character literals, for example#\newline
, and this gives us a starting point of where to search:
syn match schemeCharacter "#\\newline"
It is then just a matter of adding similar lines to the file with the new desired names...
syn match schemeCharacter "#\\linefeed"
...
Now we know that the existing file properly formats character literals where the unicode point is expressed in hexadecimal form. Searching for other occurences of schemeCharacter
we find:
syn match schemeCharacter "#\\x[0-9a-fA-F]\+"
This really looks like a way of specifying a regex expression to match hex literals preceded by #\x
. In order to add syntax recognition for character literals in octal format, we simply need to add another line of this type with the appropriate regex, this time allowing parsing of octal literals:
syn match schemeCharacter "#\\[0-7]\+"
Note: according to the GNU guile manual, R7RS uses the literal #\escape
instead of #\esc
(or as well as?). If you want both literals to be recognized by the syntax file, you cannot simply put the line relating to 'escape' first. Maybe replace the line for 'esc' by:
syn match schemeCharacter "#\\esc[^a]"
which indicates you will match any #\esc
provided it is not followed by a
.