Add vim haskell syntax files
3f55139b8e321b98c01928fa991660236c4d6a3b
1 parent
a64e80a2
.vim/syntax/cabal.vim
added
+138 -0
| 1 | + | " Vim syntax file |
|
| 2 | + | " Language: Haskell Cabal Build file |
|
| 3 | + | " Maintainer: Vincent Berthoux <twinside@gmail.com> |
|
| 4 | + | " File Types: .cabal |
|
| 5 | + | " v1.4: Add benchmark support, thanks to Simon Meier |
|
| 6 | + | " v1.3: Updated to the last version of cabal |
|
| 7 | + | " Added more highlighting for cabal function, true/false |
|
| 8 | + | " and version number. Also added missing comment highlighting. |
|
| 9 | + | " Cabal known compiler are highlighted too. |
|
| 10 | + | " |
|
| 11 | + | " V1.2: Added cpp-options which was missing. Feature implemented |
|
| 12 | + | " by GHC, found with a GHC warning, but undocumented. |
|
| 13 | + | " Whatever... |
|
| 14 | + | " |
|
| 15 | + | " v1.1: Fixed operator problems and added ftdetect file |
|
| 16 | + | " (thanks to Sebastian Schwarz) |
|
| 17 | + | " |
|
| 18 | + | " v1.0: Cabal syntax in vimball format |
|
| 19 | + | " (thanks to Magnus Therning) |
|
| 20 | + | ||
| 21 | + | " For version 5.x: Clear all syntax items |
|
| 22 | + | " For version 6.x: Quit when a syntax file was already loaded |
|
| 23 | + | if version < 600 |
|
| 24 | + | syntax clear |
|
| 25 | + | elseif exists("b:current_syntax") |
|
| 26 | + | finish |
|
| 27 | + | endif |
|
| 28 | + | ||
| 29 | + | syn match cabalCategory "\c\<executable\>" |
|
| 30 | + | syn match cabalCategory "\c\<library\>" |
|
| 31 | + | syn match cabalCategory "\c\<benchmark\>" |
|
| 32 | + | syn match cabalCategory "\c\<test-suite\>" |
|
| 33 | + | syn match cabalCategory "\c\<source-repository\>" |
|
| 34 | + | syn match cabalCategory "\c\<flag\>" |
|
| 35 | + | ||
| 36 | + | syn keyword cabalConditional if else |
|
| 37 | + | syn match cabalOperator "&&\|||\|!\|==\|>=\|<=" |
|
| 38 | + | syn keyword cabalFunction os arche impl flag |
|
| 39 | + | syn match cabalComment /--.*$/ |
|
| 40 | + | syn match cabalVersion "\d\+\(\.\(\d\)\+\)\+\(\.\*\)\?" |
|
| 41 | + | ||
| 42 | + | syn match cabalTruth "\c\<true\>" |
|
| 43 | + | syn match cabalTruth "\c\<false\>" |
|
| 44 | + | ||
| 45 | + | syn match cabalCompiler "\c\<ghc\>" |
|
| 46 | + | syn match cabalCompiler "\c\<nhc\>" |
|
| 47 | + | syn match cabalCompiler "\c\<yhc\>" |
|
| 48 | + | syn match cabalCompiler "\c\<hugs\>" |
|
| 49 | + | syn match cabalCompiler "\c\<hbc\>" |
|
| 50 | + | syn match cabalCompiler "\c\<helium\>" |
|
| 51 | + | syn match cabalCompiler "\c\<jhc\>" |
|
| 52 | + | syn match cabalCompiler "\c\<lhc\>" |
|
| 53 | + | ||
| 54 | + | syn match cabalStatement /^\c\s*\<default-language\s*:/me=e-1 |
|
| 55 | + | syn match cabalStatement /^\c\s*\<default-extensions\s*:/me=e-1 |
|
| 56 | + | ||
| 57 | + | syn match cabalStatement /^\c\s*\<author\s*:/me=e-1 |
|
| 58 | + | syn match cabalStatement /^\c\s*\<branch\s*:/me=e-1 |
|
| 59 | + | syn match cabalStatement /^\c\s*\<bug-reports\s*:/me=e-1 |
|
| 60 | + | syn match cabalStatement /^\c\s*\<build-depends\s*:/me=e-1 |
|
| 61 | + | syn match cabalStatement /^\c\s*\<build-tools\s*:/me=e-1 |
|
| 62 | + | syn match cabalStatement /^\c\s*\<build-type\s*:/me=e-1 |
|
| 63 | + | syn match cabalStatement /^\c\s*\<buildable\s*:/me=e-1 |
|
| 64 | + | syn match cabalStatement /^\c\s*\<c-sources\s*:/me=e-1 |
|
| 65 | + | syn match cabalStatement /^\c\s*\<cabal-version\s*:/me=e-1 |
|
| 66 | + | syn match cabalStatement /^\c\s*\<category\s*:/me=e-1 |
|
| 67 | + | syn match cabalStatement /^\c\s*\<cc-options\s*:/me=e-1 |
|
| 68 | + | syn match cabalStatement /^\c\s*\<copyright\s*:/me=e-1 |
|
| 69 | + | syn match cabalStatement /^\c\s*\<cpp-options\s*:/me=e-1 |
|
| 70 | + | syn match cabalStatement /^\c\s*\<data-dir\s*:/me=e-1 |
|
| 71 | + | syn match cabalStatement /^\c\s*\<data-files\s*:/me=e-1 |
|
| 72 | + | syn match cabalStatement /^\c\s*\<default\s*:/me=e-1 |
|
| 73 | + | syn match cabalStatement /^\c\s*\<description\s*:/me=e-1 |
|
| 74 | + | syn match cabalStatement /^\c\s*\<executable\s*:/me=e-1 |
|
| 75 | + | syn match cabalStatement /^\c\s*\<exposed-modules\s*:/me=e-1 |
|
| 76 | + | syn match cabalStatement /^\c\s*\<exposed\s*:/me=e-1 |
|
| 77 | + | syn match cabalStatement /^\c\s*\<extensions\s*:/me=e-1 |
|
| 78 | + | syn match cabalStatement /^\c\s*\<extra-lib-dirs\s*:/me=e-1 |
|
| 79 | + | syn match cabalStatement /^\c\s*\<extra-libraries\s*:/me=e-1 |
|
| 80 | + | syn match cabalStatement /^\c\s*\<extra-source-files\s*:/me=e-1 |
|
| 81 | + | syn match cabalStatement /^\c\s*\<extra-tmp-files\s*:/me=e-1 |
|
| 82 | + | syn match cabalStatement /^\c\s*\<for example\s*:/me=e-1 |
|
| 83 | + | syn match cabalStatement /^\c\s*\<frameworks\s*:/me=e-1 |
|
| 84 | + | syn match cabalStatement /^\c\s*\<ghc-options\s*:/me=e-1 |
|
| 85 | + | syn match cabalStatement /^\c\s*\<ghc-prof-options\s*:/me=e-1 |
|
| 86 | + | syn match cabalStatement /^\c\s*\<ghc-shared-options\s*:/me=e-1 |
|
| 87 | + | syn match cabalStatement /^\c\s*\<homepage\s*:/me=e-1 |
|
| 88 | + | syn match cabalStatement /^\c\s*\<hs-source-dirs\s*:/me=e-1 |
|
| 89 | + | syn match cabalStatement /^\c\s*\<hugs-options\s*:/me=e-1 |
|
| 90 | + | syn match cabalStatement /^\c\s*\<include-dirs\s*:/me=e-1 |
|
| 91 | + | syn match cabalStatement /^\c\s*\<includes\s*:/me=e-1 |
|
| 92 | + | syn match cabalStatement /^\c\s*\<install-includes\s*:/me=e-1 |
|
| 93 | + | syn match cabalStatement /^\c\s*\<ld-options\s*:/me=e-1 |
|
| 94 | + | syn match cabalStatement /^\c\s*\<license-file\s*:/me=e-1 |
|
| 95 | + | syn match cabalStatement /^\c\s*\<license\s*:/me=e-1 |
|
| 96 | + | syn match cabalStatement /^\c\s*\<location\s*:/me=e-1 |
|
| 97 | + | syn match cabalStatement /^\c\s*\<main-is\s*:/me=e-1 |
|
| 98 | + | syn match cabalStatement /^\c\s*\<maintainer\s*:/me=e-1 |
|
| 99 | + | syn match cabalStatement /^\c\s*\<module\s*:/me=e-1 |
|
| 100 | + | syn match cabalStatement /^\c\s*\<name\s*:/me=e-1 |
|
| 101 | + | syn match cabalStatement /^\c\s*\<nhc98-options\s*:/me=e-1 |
|
| 102 | + | syn match cabalStatement /^\c\s*\<other-modules\s*:/me=e-1 |
|
| 103 | + | syn match cabalStatement /^\c\s*\<package-url\s*:/me=e-1 |
|
| 104 | + | syn match cabalStatement /^\c\s*\<pkgconfig-depends\s*:/me=e-1 |
|
| 105 | + | syn match cabalStatement /^\c\s*\<stability\s*:/me=e-1 |
|
| 106 | + | syn match cabalStatement /^\c\s*\<subdir\s*:/me=e-1 |
|
| 107 | + | syn match cabalStatement /^\c\s*\<synopsis\s*:/me=e-1 |
|
| 108 | + | syn match cabalStatement /^\c\s*\<tag\s*:/me=e-1 |
|
| 109 | + | syn match cabalStatement /^\c\s*\<tested-with\s*:/me=e-1 |
|
| 110 | + | syn match cabalStatement /^\c\s*\<type\s*:/me=e-1 |
|
| 111 | + | syn match cabalStatement /^\c\s*\<version\s*:/me=e-1 |
|
| 112 | + | ||
| 113 | + | " Define the default highlighting. |
|
| 114 | + | " For version 5.7 and earlier: only when not done already |
|
| 115 | + | " For version 5.8 and later: only when an item doesn't have highlighting yet |
|
| 116 | + | if version >= 508 || !exists("did_cabal_syn_inits") |
|
| 117 | + | if version < 508 |
|
| 118 | + | let did_cabal_syn_inits = 1 |
|
| 119 | + | command -nargs=+ HiLink hi link <args> |
|
| 120 | + | else |
|
| 121 | + | command -nargs=+ HiLink hi def link <args> |
|
| 122 | + | endif |
|
| 123 | + | ||
| 124 | + | HiLink cabalVersion Number |
|
| 125 | + | HiLink cabalTruth Boolean |
|
| 126 | + | HiLink cabalComment Comment |
|
| 127 | + | HiLink cabalStatement Statement |
|
| 128 | + | HiLink cabalCategory Type |
|
| 129 | + | HiLink cabalFunction Function |
|
| 130 | + | HiLink cabalConditional Conditional |
|
| 131 | + | HiLink cabalOperator Operator |
|
| 132 | + | HiLink cabalCompiler Constant |
|
| 133 | + | delcommand HiLink |
|
| 134 | + | endif |
|
| 135 | + | ||
| 136 | + | let b:current_syntax = "cabal" |
|
| 137 | + | ||
| 138 | + | " vim: ts=8 |
.vim/syntax/haskell.vim
added
+354 -0
| 1 | + | " Vim syntax file |
|
| 2 | + | " |
|
| 3 | + | " Modification of vims Haskell syntax file: |
|
| 4 | + | " - match types using regular expression |
|
| 5 | + | " - highlight toplevel functions |
|
| 6 | + | " - use "syntax keyword" instead of "syntax match" where appropriate |
|
| 7 | + | " - functions and types in import and module declarations are matched |
|
| 8 | + | " - removed hs_highlight_more_types (just not needed anymore) |
|
| 9 | + | " - enable spell checking in comments and strings only |
|
| 10 | + | " - FFI highlighting |
|
| 11 | + | " - QuasiQuotation |
|
| 12 | + | " - top level Template Haskell slices |
|
| 13 | + | " - PackageImport |
|
| 14 | + | " |
|
| 15 | + | " TODO: find out which vim versions are still supported |
|
| 16 | + | " |
|
| 17 | + | " From Original file: |
|
| 18 | + | " =================== |
|
| 19 | + | " |
|
| 20 | + | " Language: Haskell |
|
| 21 | + | " Maintainer: Haskell Cafe mailinglist <haskell-cafe@haskell.org> |
|
| 22 | + | " Last Change: 2010 Feb 21 |
|
| 23 | + | " Original Author: John Williams <jrw@pobox.com> |
|
| 24 | + | " |
|
| 25 | + | " Thanks to Ryan Crumley for suggestions and John Meacham for |
|
| 26 | + | " pointing out bugs. Also thanks to Ian Lynagh and Donald Bruce Stewart |
|
| 27 | + | " for providing the inspiration for the inclusion of the handling |
|
| 28 | + | " of C preprocessor directives, and for pointing out a bug in the |
|
| 29 | + | " end-of-line comment handling. |
|
| 30 | + | " |
|
| 31 | + | " Options-assign a value to these variables to turn the option on: |
|
| 32 | + | " |
|
| 33 | + | " hs_highlight_delimiters - Highlight delimiter characters--users |
|
| 34 | + | " with a light-colored background will |
|
| 35 | + | " probably want to turn this on. |
|
| 36 | + | " hs_highlight_boolean - Treat True and False as keywords. |
|
| 37 | + | " hs_highlight_types - Treat names of primitive types as keywords. |
|
| 38 | + | " hs_highlight_debug - Highlight names of debugging functions. |
|
| 39 | + | " hs_allow_hash_operator - Don't highlight seemingly incorrect C |
|
| 40 | + | " preprocessor directives but assume them to be |
|
| 41 | + | " operators |
|
| 42 | + | " |
|
| 43 | + | " |
|
| 44 | + | ||
| 45 | + | if version < 600 |
|
| 46 | + | syn clear |
|
| 47 | + | elseif exists("b:current_syntax") |
|
| 48 | + | finish |
|
| 49 | + | endif |
|
| 50 | + | ||
| 51 | + | "syntax sync fromstart "mmhhhh.... is this really ok to do so? |
|
| 52 | + | syntax sync linebreaks=15 minlines=50 maxlines=500 |
|
| 53 | + | ||
| 54 | + | syn match hsSpecialChar contained "\\\([0-9]\+\|o[0-7]\+\|x[0-9a-fA-F]\+\|[\"\\'&\\abfnrtv]\|^[A-Z^_\[\\\]]\)" |
|
| 55 | + | syn match hsSpecialChar contained "\\\(NUL\|SOH\|STX\|ETX\|EOT\|ENQ\|ACK\|BEL\|BS\|HT\|LF\|VT\|FF\|CR\|SO\|SI\|DLE\|DC1\|DC2\|DC3\|DC4\|NAK\|SYN\|ETB\|CAN\|EM\|SUB\|ESC\|FS\|GS\|RS\|US\|SP\|DEL\)" |
|
| 56 | + | syn match hsSpecialCharError contained "\\&\|'''\+" |
|
| 57 | + | sy region hsString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=hsSpecialChar,@Spell |
|
| 58 | + | sy match hsCharacter "[^a-zA-Z0-9_']'\([^\\]\|\\[^']\+\|\\'\)'"lc=1 contains=hsSpecialChar,hsSpecialCharError |
|
| 59 | + | sy match hsCharacter "^'\([^\\]\|\\[^']\+\|\\'\)'" contains=hsSpecialChar,hsSpecialCharError |
|
| 60 | + | ||
| 61 | + | " (Qualified) identifiers (no default highlighting) |
|
| 62 | + | syn match ConId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[A-Z][a-zA-Z0-9_']*\>" |
|
| 63 | + | syn match VarId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[a-z][a-zA-Z0-9_']*\>" |
|
| 64 | + | ||
| 65 | + | " Infix operators--most punctuation characters and any (qualified) identifier |
|
| 66 | + | " enclosed in `backquotes`. An operator starting with : is a constructor, |
|
| 67 | + | " others are variables (e.g. functions). |
|
| 68 | + | syn match hsVarSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[-!#$%&\*\+/<=>\?@\\^|~.][-!#$%&\*\+/<=>\?@\\^|~:.]*" |
|
| 69 | + | syn match hsConSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=:[-!#$%&\*\+./<=>\?@\\^|~:]*" |
|
| 70 | + | syn match hsVarSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[a-z][a-zA-Z0-9_']*`" |
|
| 71 | + | syn match hsConSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[A-Z][a-zA-Z0-9_']*`" |
|
| 72 | + | ||
| 73 | + | " Toplevel Template Haskell support |
|
| 74 | + | "sy match hsTHTopLevel "^[a-z]\(\(.\&[^=]\)\|\(\n[^a-zA-Z0-9]\)\)*" |
|
| 75 | + | sy match hsTHIDTopLevel "^[a-z]\S*" |
|
| 76 | + | sy match hsTHTopLevel "^\$(\?" nextgroup=hsTHTopLevelName |
|
| 77 | + | sy match hsTHTopLevelName "[a-z]\S*" contained |
|
| 78 | + | ||
| 79 | + | " Reserved symbols--cannot be overloaded. |
|
| 80 | + | syn match hsDelimiter "(\|)\|\[\|\]\|,\|;\|_\|{\|}" |
|
| 81 | + | ||
| 82 | + | sy region hsInnerParen start="(" end=")" contained contains=hsInnerParen,hsConSym,hsType,hsVarSym |
|
| 83 | + | sy region hs_InfixOpFunctionName start="^(" end=")\s*[^:`]\(\W\&\S\&[^'\"`()[\]{}@]\)\+"re=s |
|
| 84 | + | \ contained keepend contains=hsInnerParen,hs_HlInfixOp |
|
| 85 | + | ||
| 86 | + | sy match hs_hlFunctionName "[a-z_]\(\S\&[^,\(\)\[\]]\)*" contained |
|
| 87 | + | sy match hs_FunctionName "^[a-z_]\(\S\&[^,\(\)\[\]]\)*" contained contains=hs_hlFunctionName |
|
| 88 | + | sy match hs_HighliteInfixFunctionName "`[a-z_][^`]*`" contained |
|
| 89 | + | sy match hs_InfixFunctionName "^\S[^=]*`[a-z_][^`]*`"me=e-1 contained contains=hs_HighliteInfixFunctionName,hsType,hsConSym,hsVarSym,hsString,hsCharacter |
|
| 90 | + | sy match hs_HlInfixOp "\(\W\&\S\&[^`(){}'[\]]\)\+" contained contains=hsString |
|
| 91 | + | sy match hs_InfixOpFunctionName "^\(\(\w\|[[\]{}]\)\+\|\(\".*\"\)\|\('.*'\)\)\s*[^:]=*\(\W\&\S\&[^='\"`()[\]{}@]\)\+" |
|
| 92 | + | \ contained contains=hs_HlInfixOp,hsCharacter |
|
| 93 | + | ||
| 94 | + | sy match hs_OpFunctionName "(\(\W\&[^(),\"]\)\+)" contained |
|
| 95 | + | "sy region hs_Function start="^["'a-z_([{]" end="=\(\s\|\n\|\w\|[([]\)" keepend extend |
|
| 96 | + | sy region hs_Function start="^["'a-zA-Z_([{]\(\(.\&[^=]\)\|\(\n\s\)\)*=" end="\(\s\|\n\|\w\|[([]\)" |
|
| 97 | + | \ contains=hs_OpFunctionName,hs_InfixOpFunctionName,hs_InfixFunctionName,hs_FunctionName,hsType,hsConSym,hsVarSym,hsString,hsCharacter |
|
| 98 | + | ||
| 99 | + | sy match hs_DeclareFunction "^[a-z_(]\S*\(\s\|\n\)*::" contains=hs_FunctionName,hs_OpFunctionName |
|
| 100 | + | ||
| 101 | + | " hi hs_InfixOpFunctionName guibg=bg |
|
| 102 | + | " hi hs_Function guibg=green |
|
| 103 | + | " hi hs_InfixFunctionName guibg=red |
|
| 104 | + | " hi hs_DeclareFunction guibg=red |
|
| 105 | + | ||
| 106 | + | sy keyword hsStructure data family class where instance default deriving |
|
| 107 | + | sy keyword hsTypedef type newtype |
|
| 108 | + | ||
| 109 | + | sy keyword hsInfix infix infixl infixr |
|
| 110 | + | sy keyword hsStatement do case of let in |
|
| 111 | + | sy keyword hsConditional if then else |
|
| 112 | + | ||
| 113 | + | "if exists("hs_highlight_types") |
|
| 114 | + | " Primitive types from the standard prelude and libraries. |
|
| 115 | + | sy match hsType "\<[A-Z]\(\S\&[^,.]\)*\>" |
|
| 116 | + | sy match hsType "()" |
|
| 117 | + | "endif |
|
| 118 | + | ||
| 119 | + | " Not real keywords, but close. |
|
| 120 | + | if exists("hs_highlight_boolean") |
|
| 121 | + | " Boolean constants from the standard prelude. |
|
| 122 | + | syn keyword hsBoolean True False |
|
| 123 | + | endif |
|
| 124 | + | ||
| 125 | + | syn region hsPackageString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial contained |
|
| 126 | + | sy match hsModuleName excludenl "\([A-Z]\w*\.\?\)*" contained |
|
| 127 | + | ||
| 128 | + | sy match hsImport "\<import\>\s\+\(qualified\s\+\)\?\(\<\(\w\|\.\)*\>\)" |
|
| 129 | + | \ contains=hsModuleName,hsImportLabel |
|
| 130 | + | \ nextgroup=hsImportParams,hsImportIllegal skipwhite |
|
| 131 | + | sy keyword hsImportLabel import qualified contained |
|
| 132 | + | ||
| 133 | + | sy match hsImportIllegal "\w\+" contained |
|
| 134 | + | ||
| 135 | + | sy keyword hsAsLabel as contained |
|
| 136 | + | sy keyword hsHidingLabel hiding contained |
|
| 137 | + | ||
| 138 | + | sy match hsImportParams "as\s\+\(\w\+\)" contained |
|
| 139 | + | \ contains=hsModuleName,hsAsLabel |
|
| 140 | + | \ nextgroup=hsImportParams,hsImportIllegal skipwhite |
|
| 141 | + | sy match hsImportParams "hiding" contained |
|
| 142 | + | \ contains=hsHidingLabel |
|
| 143 | + | \ nextgroup=hsImportParams,hsImportIllegal skipwhite |
|
| 144 | + | sy region hsImportParams start="(" end=")" contained |
|
| 145 | + | \ contains=hsBlockComment,hsLineComment, hsType,hsDelimTypeExport,hs_hlFunctionName,hs_OpFunctionName |
|
| 146 | + | \ nextgroup=hsImportIllegal skipwhite |
|
| 147 | + | ||
| 148 | + | " hi hsImport guibg=red |
|
| 149 | + | "hi hsImportParams guibg=bg |
|
| 150 | + | "hi hsImportIllegal guibg=bg |
|
| 151 | + | "hi hsModuleName guibg=bg |
|
| 152 | + | ||
| 153 | + | "sy match hsImport "\<import\>\(.\|[^(]\)*\((.*)\)\?" |
|
| 154 | + | " \ contains=hsPackageString,hsImportLabel,hsImportMod,hsModuleName,hsImportList |
|
| 155 | + | "sy keyword hsImportLabel import contained |
|
| 156 | + | "sy keyword hsImportMod as qualified hiding contained |
|
| 157 | + | "sy region hsImportListInner start="(" end=")" contained keepend extend contains=hs_OpFunctionName |
|
| 158 | + | "sy region hsImportList matchgroup=hsImportListParens start="("rs=s+1 end=")"re=e-1 |
|
| 159 | + | " \ contained |
|
| 160 | + | " \ keepend extend |
|
| 161 | + | " \ contains=hsType,hsLineComment,hsBlockComment,hs_hlFunctionName,hsImportListInner |
|
| 162 | + | ||
| 163 | + | ||
| 164 | + | ||
| 165 | + | " new module highlighting |
|
| 166 | + | syn region hsDelimTypeExport start="\<[A-Z]\(\S\&[^,.]\)*\>(" end=")" contained |
|
| 167 | + | \ contains=hsType |
|
| 168 | + | ||
| 169 | + | sy keyword hsExportModuleLabel module contained |
|
| 170 | + | sy match hsExportModule "\<module\>\(\s\|\t\|\n\)*\([A-Z]\w*\.\?\)*" contained contains=hsExportModuleLabel,hsModuleName |
|
| 171 | + | ||
| 172 | + | sy keyword hsModuleStartLabel module contained |
|
| 173 | + | sy keyword hsModuleWhereLabel where contained |
|
| 174 | + | ||
| 175 | + | syn match hsModuleStart "^module\(\s\|\n\)*\(\<\(\w\|\.\)*\>\)\(\s\|\n\)*" |
|
| 176 | + | \ contains=hsModuleStartLabel,hsModuleName |
|
| 177 | + | \ nextgroup=hsModuleCommentA,hsModuleExports,hsModuleWhereLabel |
|
| 178 | + | ||
| 179 | + | syn region hsModuleCommentA start="{-" end="-}" |
|
| 180 | + | \ contains=hsModuleCommentA,hsCommentTodo,@Spell contained |
|
| 181 | + | \ nextgroup=hsModuleCommentA,hsModuleExports,hsModuleWhereLabel skipwhite skipnl |
|
| 182 | + | ||
| 183 | + | syn match hsModuleCommentA "--.*\n" |
|
| 184 | + | \ contains=hsCommentTodo,@Spell contained |
|
| 185 | + | \ nextgroup=hsModuleCommentA,hsModuleExports,hsModuleWhereLabel skipwhite skipnl |
|
| 186 | + | ||
| 187 | + | syn region hsModuleExports start="(" end=")" contained |
|
| 188 | + | \ nextgroup=hsModuleCommentB,hsModuleWhereLabel skipwhite skipnl |
|
| 189 | + | \ contains=hsBlockComment,hsLineComment,hsType,hsDelimTypeExport,hs_hlFunctionName,hs_OpFunctionName,hsExportModule |
|
| 190 | + | ||
| 191 | + | syn match hsModuleCommentB "--.*\n" |
|
| 192 | + | \ contains=hsCommentTodo,@Spell contained |
|
| 193 | + | \ nextgroup=hsModuleCommentB,hsModuleWhereLabel skipwhite skipnl |
|
| 194 | + | ||
| 195 | + | syn region hsModuleCommentB start="{-" end="-}" |
|
| 196 | + | \ contains=hsModuleCommentB,hsCommentTodo,@Spell contained |
|
| 197 | + | \ nextgroup=hsModuleCommentB,hsModuleWhereLabel skipwhite skipnl |
|
| 198 | + | " end module highlighting |
|
| 199 | + | ||
| 200 | + | " FFI support |
|
| 201 | + | sy keyword hsFFIForeign foreign contained |
|
| 202 | + | "sy keyword hsFFIImportExport import export contained |
|
| 203 | + | sy keyword hsFFIImportExport export contained |
|
| 204 | + | sy keyword hsFFICallConvention ccall stdcall contained |
|
| 205 | + | sy keyword hsFFISafety safe unsafe contained |
|
| 206 | + | sy region hsFFIString start=+"+ skip=+\\\\\|\\"+ end=+"+ contained contains=hsSpecialChar |
|
| 207 | + | sy match hsFFI excludenl "\<foreign\>\(.\&[^\"]\)*\"\(.\)*\"\(\s\|\n\)*\(.\)*::" |
|
| 208 | + | \ keepend |
|
| 209 | + | \ contains=hsFFIForeign,hsFFIImportExport,hsFFICallConvention,hsFFISafety,hsFFIString,hs_OpFunctionName,hs_hlFunctionName |
|
| 210 | + | ||
| 211 | + | ||
| 212 | + | sy match hsNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>" |
|
| 213 | + | sy match hsFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>" |
|
| 214 | + | ||
| 215 | + | " Comments |
|
| 216 | + | sy keyword hsCommentTodo TODO FIXME XXX TBD contained |
|
| 217 | + | sy match hsLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=hsCommentTodo,@Spell |
|
| 218 | + | sy region hsBlockComment start="{-" end="-}" contains=hsBlockComment,hsCommentTodo,@Spell |
|
| 219 | + | sy region hsPragma start="{-#" end="#-}" |
|
| 220 | + | ||
| 221 | + | " QuasiQuotation |
|
| 222 | + | sy region hsQQ start="\[\$" end="|\]"me=e-2 keepend contains=hsQQVarID,hsQQContent nextgroup=hsQQEnd |
|
| 223 | + | sy region hsQQNew start="\[\(.\&[^|]\&\S\)*|" end="|\]"me=e-2 keepend contains=hsQQVarIDNew,hsQQContent nextgroup=hsQQEnd |
|
| 224 | + | sy match hsQQContent ".*" contained |
|
| 225 | + | sy match hsQQEnd "|\]" contained |
|
| 226 | + | sy match hsQQVarID "\[\$\(.\&[^|]\)*|" contained |
|
| 227 | + | sy match hsQQVarIDNew "\[\(.\&[^|]\)*|" contained |
|
| 228 | + | ||
| 229 | + | if exists("hs_highlight_debug") |
|
| 230 | + | " Debugging functions from the standard prelude. |
|
| 231 | + | syn keyword hsDebug undefined error trace |
|
| 232 | + | endif |
|
| 233 | + | ||
| 234 | + | ||
| 235 | + | " C Preprocessor directives. Shamelessly ripped from c.vim and trimmed |
|
| 236 | + | " First, see whether to flag directive-like lines or not |
|
| 237 | + | if (!exists("hs_allow_hash_operator")) |
|
| 238 | + | syn match cError display "^\s*\(%:\|#\).*$" |
|
| 239 | + | endif |
|
| 240 | + | " Accept %: for # (C99) |
|
| 241 | + | syn region cPreCondit start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=cComment,cCppString,cCommentError |
|
| 242 | + | syn match cPreCondit display "^\s*\(%:\|#\)\s*\(else\|endif\)\>" |
|
| 243 | + | syn region cCppOut start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2 |
|
| 244 | + | syn region cCppOut2 contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=cCppSkip |
|
| 245 | + | syn region cCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cCppSkip |
|
| 246 | + | syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ |
|
| 247 | + | syn match cIncluded display contained "<[^>]*>" |
|
| 248 | + | syn match cInclude display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded |
|
| 249 | + | syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cCppOut,cCppOut2,cCppSkip,cCommentStartError |
|
| 250 | + | syn region cDefine matchgroup=cPreCondit start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" |
|
| 251 | + | syn region cPreProc matchgroup=cPreCondit start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend |
|
| 252 | + | ||
| 253 | + | syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=cCommentStartError,cSpaceError contained |
|
| 254 | + | syntax match cCommentError display "\*/" contained |
|
| 255 | + | syntax match cCommentStartError display "/\*"me=e-1 contained |
|
| 256 | + | syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial contained |
|
| 257 | + | ||
| 258 | + | ||
| 259 | + | if version >= 508 || !exists("did_hs_syntax_inits") |
|
| 260 | + | if version < 508 |
|
| 261 | + | let did_hs_syntax_inits = 1 |
|
| 262 | + | command -nargs=+ HiLink hi link <args> |
|
| 263 | + | else |
|
| 264 | + | command -nargs=+ HiLink hi def link <args> |
|
| 265 | + | endif |
|
| 266 | + | ||
| 267 | + | HiLink hs_hlFunctionName Function |
|
| 268 | + | HiLink hs_HighliteInfixFunctionName Function |
|
| 269 | + | HiLink hs_HlInfixOp Function |
|
| 270 | + | HiLink hs_OpFunctionName Function |
|
| 271 | + | HiLink hsTypedef Typedef |
|
| 272 | + | HiLink hsVarSym hsOperator |
|
| 273 | + | HiLink hsConSym hsOperator |
|
| 274 | + | if exists("hs_highlight_delimiters") |
|
| 275 | + | " Some people find this highlighting distracting. |
|
| 276 | + | HiLink hsDelimiter Delimiter |
|
| 277 | + | endif |
|
| 278 | + | ||
| 279 | + | HiLink hsModuleStartLabel Structure |
|
| 280 | + | HiLink hsExportModuleLabel Keyword |
|
| 281 | + | HiLink hsModuleWhereLabel Structure |
|
| 282 | + | HiLink hsModuleName Normal |
|
| 283 | + | ||
| 284 | + | HiLink hsImportIllegal Error |
|
| 285 | + | HiLink hsAsLabel hsImportLabel |
|
| 286 | + | HiLink hsHidingLabel hsImportLabel |
|
| 287 | + | HiLink hsImportLabel Include |
|
| 288 | + | HiLink hsImportMod Include |
|
| 289 | + | HiLink hsPackageString hsString |
|
| 290 | + | ||
| 291 | + | HiLink hsOperator Operator |
|
| 292 | + | ||
| 293 | + | HiLink hsInfix Keyword |
|
| 294 | + | HiLink hsStructure Structure |
|
| 295 | + | HiLink hsStatement Statement |
|
| 296 | + | HiLink hsConditional Conditional |
|
| 297 | + | ||
| 298 | + | HiLink hsSpecialCharError Error |
|
| 299 | + | HiLink hsSpecialChar SpecialChar |
|
| 300 | + | HiLink hsString String |
|
| 301 | + | HiLink hsFFIString String |
|
| 302 | + | HiLink hsCharacter Character |
|
| 303 | + | HiLink hsNumber Number |
|
| 304 | + | HiLink hsFloat Float |
|
| 305 | + | ||
| 306 | + | HiLink hsLiterateComment hsComment |
|
| 307 | + | HiLink hsBlockComment hsComment |
|
| 308 | + | HiLink hsLineComment hsComment |
|
| 309 | + | HiLink hsModuleCommentA hsComment |
|
| 310 | + | HiLink hsModuleCommentB hsComment |
|
| 311 | + | HiLink hsComment Comment |
|
| 312 | + | HiLink hsCommentTodo Todo |
|
| 313 | + | HiLink hsPragma SpecialComment |
|
| 314 | + | HiLink hsBoolean Boolean |
|
| 315 | + | ||
| 316 | + | if exists("hs_highlight_types") |
|
| 317 | + | HiLink hsDelimTypeExport hsType |
|
| 318 | + | HiLink hsType Type |
|
| 319 | + | endif |
|
| 320 | + | ||
| 321 | + | HiLink hsDebug Debug |
|
| 322 | + | ||
| 323 | + | HiLink cCppString hsString |
|
| 324 | + | HiLink cCommentStart hsComment |
|
| 325 | + | HiLink cCommentError hsError |
|
| 326 | + | HiLink cCommentStartError hsError |
|
| 327 | + | HiLink cInclude Include |
|
| 328 | + | HiLink cPreProc PreProc |
|
| 329 | + | HiLink cDefine Macro |
|
| 330 | + | HiLink cIncluded hsString |
|
| 331 | + | HiLink cError Error |
|
| 332 | + | HiLink cPreCondit PreCondit |
|
| 333 | + | HiLink cComment Comment |
|
| 334 | + | HiLink cCppSkip cCppOut |
|
| 335 | + | HiLink cCppOut2 cCppOut |
|
| 336 | + | HiLink cCppOut Comment |
|
| 337 | + | ||
| 338 | + | HiLink hsFFIForeign Keyword |
|
| 339 | + | HiLink hsFFIImportExport Structure |
|
| 340 | + | HiLink hsFFICallConvention Keyword |
|
| 341 | + | HiLink hsFFISafety Keyword |
|
| 342 | + | ||
| 343 | + | HiLink hsTHIDTopLevel Macro |
|
| 344 | + | HiLink hsTHTopLevelName Macro |
|
| 345 | + | ||
| 346 | + | HiLink hsQQVarID Keyword |
|
| 347 | + | HiLink hsQQVarIDNew Keyword |
|
| 348 | + | HiLink hsQQEnd Keyword |
|
| 349 | + | HiLink hsQQContent String |
|
| 350 | + | ||
| 351 | + | delcommand HiLink |
|
| 352 | + | endif |
|
| 353 | + | ||
| 354 | + | let b:current_syntax = "haskell" |