language-haskell icon indicating copy to clipboard operation
language-haskell copied to clipboard

Highlighting for haddocks

Open sheaf opened this issue 5 years ago • 7 comments

As per the haddock documentation, Haskell code can appear in Haddock comments in the following ways:

-- code blocks:
-- @ 
--    f :: a -> a
--    f a = a
-- @ 
--
-- bird tracks:
-- > f 12
--
-- REPL examples:
-- >>> f 12

There are also delimiters for LaTeX: \( ... \) (inline equation) and \[ ... \] (displayed equation).

It would be nice if highlighting could be enabled for those cases.

Some other extra highlighting that could be done:

  • headings with = == ===, ...
  • named chunks $chunkname
  • *bold* and /italics/
  • @since annotations
  • URLs (VS Code automatically makes URLs clickable)

I think we could have a special haddock grammar file that we could include in the main Haskell grammar for Haddock comments.

sheaf avatar May 01 '20 02:05 sheaf

Some improvements to Haddock support in a0b8ea7, detecting more Haddock comment blocks than before (such as those starting with -- ^).

sheaf avatar May 03 '20 12:05 sheaf

Dude having full on haddock highlighting would be so nice! I don't think any of the other extensions do haddock?

JustusAdam avatar May 03 '20 19:05 JustusAdam

Haddock also have lists, maybe we can "borrow" part of the matching rules from markdown?

I'd almost recommend we start a new syntax file for haddock and include it from the Haskell one. What do you think?

JustusAdam avatar May 03 '20 19:05 JustusAdam

Yes a separate haddock grammar file is what I had in mind too. Do you think you could start one?

sheaf avatar May 03 '20 19:05 sheaf

Sure. I'll try to do that. I don't know when yet though.

JustusAdam avatar May 06 '20 10:05 JustusAdam

We should also include the Haddock grammar to highlight the description field in .cabal files.

sheaf avatar May 08 '20 20:05 sheaf

As you may have seen I started the grammar. However I decided to publish a release for the many fixes separately first, because I expect this will take a bit more time with bug fixing the grammar (particularly code embedding) and then writing tests etc.

JustusAdam avatar May 11 '20 14:05 JustusAdam