martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.23k stars 256 forks source link

Haskell syntax coloring bug #888

Closed machinedgod closed 3 years ago

machinedgod commented 3 years ago

Hi, there's a small syntax coloring bug in haskell colorizer, specifically regarding the -- operator which marks beginning of the line comment. There are various other operators (practically an infinite number, since they can be user-created) that start with --, that aren't comments, for example --| for documentation, or --> as an operator in xmonad.

I am not quite sure if a trailing space is required to specifically start a comment, but perhaps, this would be a nice quick fix since I've never seen a comment in the wild without one.

So to sum it up:

erf commented 3 years ago

You could change that in lua/lexers/haskell.lua

Using Lua pattern, try to change "--" to "--%s"

machinedgod commented 3 years ago

Hi @erf, thank you for the tip, I'll submit the patch as well.

Edit: I didn't want to do a hackjob, so I went reading the grammar reference and it seems that comment really is everything that starts with two dashes, and is followed by anything.

I am really not sure how vim syntax coloring distinguishes from valid operators and comments (I'm guessing, a hardcoded override list for known operators, such as lenses and popular libraries), but I figured - perhaps its the best to follow the grammar rules.