Fix comment syntax highlighting for Haskell (#8135)

This adds syntax highlighting for block comments `{- ... -}` and
configuration to support the “add comment” and “remove comment” keyboard
shortcuts.
This commit is contained in:
narpfel
2025-10-08 21:56:53 +02:00
committed by GitHub
parent 3fc36bb322
commit 98a417aa2c

View File

@@ -77,20 +77,30 @@ function definition(): monaco.languages.IMonarchLanguage {
],
comment: [
[/[^/*]+/, 'comment'],
[/\*\//, 'comment', '@pop'],
[/[/*]/, 'comment'],
[/[^{-]+/, 'comment'],
[/{-/, 'comment', '@push'],
[/-}/, 'comment', '@pop'],
[/[{-]/, 'comment'],
],
whitespace: [
[/[ \t\r\n]+/, 'white'],
[/\/\*/, 'comment', '@comment'],
[/\/\/.*$/, 'comment'],
[/{-/, 'comment', '@comment'],
[/--.*$/, 'comment'],
],
},
};
}
function configuration(): monaco.languages.LanguageConfiguration {
return {
comments: {
lineComment: '--',
blockComment: ['{-', '-}'],
},
};
}
monaco.languages.register({id: 'haskell'});
monaco.languages.setMonarchTokensProvider('haskell', definition());
monaco.languages.setLanguageConfiguration('haskell', configuration());