jgm / skylighting

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions
195 stars 63 forks source link

Add loadValidSyntaxesFromDir #192

Closed kquick closed 5 months ago

kquick commented 5 months ago

The existing loadSyntaxesFromDir function is an all-or-nothing function: a single invalid file results in a error and no loaded syntaxes.

This adds the loadValidSyntaxesFromDir parallel function which is resilient against individual syntax file load failures. It returns a map of the failure messages, and the SyntaxMap that is created from all the successful parsing.

While the implementation is fairly trivial when implemented here, it makes use of local functions in this module and existing imports; duplicating that internal functionality and set of imports externally are not insignificant, thus the tradeoff against the expanded API surface is probably justified.