|
| 1 | +""""""""""" |
| 2 | +" Syntax: |
| 3 | +" |
| 4 | +" Custom syntax highlighting for GHCi in the embeded terminal window. |
| 5 | +""""""""""" |
| 6 | + |
| 7 | +" Because we have some regex that use non-ASCII characters |
| 8 | +scriptencoding utf-8 |
| 9 | + |
| 10 | +syntax include @haskell syntax/haskell.vim |
| 11 | + |
| 12 | +" Try to distinguish between GHC output and GHCi prompt lines, so that we can |
| 13 | +" enable Haskell highlighting on the GHCi prompts. |
| 14 | +exe 'syntax region GhciLine matchgroup=GhciLinePrompt start=/^'.g:intero_prompt_regex.'/ matchgroup=NONE end=/\n/ oneline keepend contains=@haskell,GhciCommand,GhciLoadCommand' |
| 15 | +syntax match GhciCommand /:[a-z-]\+/ contained |
| 16 | +syntax match GhciLoadCommand /:l.*/ contained contains=GhciCommand |
| 17 | + |
| 18 | +" ----- GHC output ---------------------------------------------------------- |
| 19 | +" Some rather ad-hoc regexes for GHC output. |
| 20 | + |
| 21 | +" For when the modules are loaded / reloaded by GHCi. |
| 22 | +syntax region GhciSteps start=/^\[\s*\d\+ of \s*\d\+\]/ end=/)/ |
| 23 | +syntax region GhciOk start=/^Ok, modules loaded:/ end=/\.$/ |
| 24 | + |
| 25 | +" Experimentally, it seems like GHC outputs "expected/actual" results in one |
| 26 | +" of two formats. Ideally, we'd have match group names describing when one |
| 27 | +" format isused over another. |
| 28 | +syntax region GhciExpectedActual1 start=/\(expected\|actual\) type/ end=/’/ keepend contains=GhciQuotedType |
| 29 | +syntax region GhciQuotedType start=/‘/ end=/’/ contained keepend |
| 30 | +syntax region GhciExpectedActual2 matchgroup=Constant start=/\(Expected\|Actual\) type: / end=/$/ |
| 31 | + |
| 32 | +syntax match GhciCause /^\s*• \(Probable\|Possible\) cause: .*$/ |
| 33 | +syntax match GhciFix /^\s*\(Probable\|Possible\) fix: .*$/ |
| 34 | +syntax region GhciPerhapsRegion matchgroup=GhciPerhapsYouMeant start=/^\z(\s*\)Perhaps you meant/ matchgroup=NONE end=/^\z1\S/ contains=GhciPerhapsSuggestion |
| 35 | +syntax region GhciPerhapsSuggestion start=/‘/ end=/’/ contained keepend |
| 36 | + |
| 37 | + |
| 38 | +" ----- Default highlight groups -------------------------------------------- |
| 39 | +" Used only if the user's colorscheme doesn't provide its own defaults. |
| 40 | +" In particular, you can configure these for yourself in your vimrc! |
| 41 | + |
| 42 | +" We ignore the prompt GHCi prompts without ANSI color codes don't pick up |
| 43 | +" styles from the underlying Haskell syntax groups. |
| 44 | +hi def link GhciLinePrompt Ignore |
| 45 | +hi def link GhciCommand PreProc |
| 46 | +hi def link GhciLoadCommand Constant |
| 47 | + |
| 48 | +hi def link GhciExpectedActual1 Constant |
| 49 | +hi def link GhciQuotedType Type |
| 50 | +hi def link GhciExpectedActual2 Type |
| 51 | + |
| 52 | +hi def link GhciSteps Comment |
| 53 | +hi def link GhciOk Statement |
| 54 | + |
| 55 | +hi def link GhciCause Underlined |
| 56 | +hi def link GhciFix Underlined |
| 57 | +hi def link GhciPerhapsYouMeant Underlined |
| 58 | +hi def link GhciPerhapsSuggestion Statement |
| 59 | + |
0 commit comments