Documentation comment highlighting (w/ possible solution)
dkimbel opened this issue · 5 comments
It looks like |||
documentation comments only receive syntax highlighting when they start a line or are preceded exclusively by whitespace. So, for instance, the documentation comments in the Type-Driven Development with Idris code blurb below are not fully highlighted.
||| Represents shapes
data Shape = ||| A triangle, with its base length and height
Triangle Double Double
| ||| A rectangle, with its length and height
Rectangle Double Double
| ||| A circle, with its radius
Circle Double
By tweaking idris-syntax.el
locally, I was able to get highlighting to work for that code.
The change I made was to mostly duplicate idris-syntax.el
's lines 234-236 in a new apply-partially
block on line 237:
(,(apply-partially #'idris-font-lock-literate-search "\\s-*\\(|||\\)\\(.*\\)$" (idris-lidr-p))
(1 font-lock-comment-delimiter-face)
(2 'idris-inline-doc-face))
I'm very much an Emacs newbie -- there's most likely a more elegant solution. I wasn't able to find a straightforward update that wouldn't still require the earlier line-start
call using the same regex pattern, though.
If you'd like me to open a PR with that update, I can -- also, if you have any pointers on a better solution, I'd be very happy to make changes. In any case, thanks for idris-mode
and your work on Idris itself!
@techowl I am pretty much an emacs newbie too :) Could you please open PR? I will try to see if I can come up with a better solution starting from it or else merge it.
The Font Lock stuff is pretty hairy, unfortunately, because it tries to support both .lidr files and .idr files. I suspect that what you've written can't be a whole lot simpler without redoing the whole approach.
When writing the mode (and adding the |||
syntax), I hadn't even considered |||
not being at the start of a line! Just goes to show how languages are extra fun :-)