JustusAdam / language-haskell

Highlighting support for the Haskell language in visual studio code.
https://marketplace.visualstudio.com/items/justusadam.language-haskell
BSD 3-Clause "New" or "Revised" License
95 stars 49 forks source link

Highlighting for haddocks #142

Open sheaf opened 4 years ago

sheaf commented 4 years ago

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:

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

sheaf commented 4 years ago

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

JustusAdam commented 4 years ago

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

JustusAdam commented 4 years ago

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?

sheaf commented 4 years ago

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

JustusAdam commented 4 years ago

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

sheaf commented 4 years ago

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

JustusAdam commented 4 years ago

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.