summaryrefslogtreecommitdiffstats
path: root/syntax
diff options
context:
space:
mode:
Diffstat (limited to 'syntax')
-rw-r--r--syntax/cabal.vim147
-rw-r--r--syntax/haskell.vim467
2 files changed, 281 insertions, 333 deletions
diff --git a/syntax/cabal.vim b/syntax/cabal.vim
new file mode 100644
index 00000000..d0510097
--- /dev/null
+++ b/syntax/cabal.vim
@@ -0,0 +1,147 @@
+" Vim syntax file
+" Language: Cabal
+" Author: Tristan Ravitch
+" Version: 0.0.1
+
+if version < 600
+ syntax clear
+elseif exists('b:current_syntax')
+ finish
+endif
+
+syn sync minlines=50 maxlines=200
+syn case ignore
+
+" Top-level package keywords
+syn match cabalKey '^name:'
+syn match cabalKey '^version:'
+syn match cabalKey '^cabal-version:'
+syn match cabalKey '^build-type:'
+syn match cabalKey '^license:'
+syn match cabalKey '^license-file:'
+syn match cabalKey '^copyright:'
+syn match cabalKey '^author:'
+syn match cabalKey '^maintainer:'
+syn match cabalKey '^stability:'
+syn match cabalKey '^homepage:'
+syn match cabalKey '^bug-reports:'
+syn match cabalKey '^package-url:'
+syn match cabalKey '^synopsis:'
+syn match cabalKey '^description:'
+syn match cabalKey '^category:'
+syn match cabalKey '^tested-with:'
+syn match cabalKey '^data-files:'
+syn match cabalKey '^data-dir:'
+syn match cabalKey '^extra-source-files:'
+syn match cabalKey '^extra-tmp-files:'
+
+" Other keywords
+syn match cabalLit '\(:\s*\)\@<=\(true\|false\)'
+
+" Library-specifics
+syn region cabalLibraryR start='^library\(\s\|$\)\@=' end='^\w' transparent keepend contains=cabalLibrayKey,cabalBuildKey,cabalCondition,cabalOperator
+syn match cabalLibraryKey '^library\(\s\|$\)\@='
+syn match cabalLibraryKey '\(^\s\+\)\@<=exposed-modules:'
+syn match cabalLibraryKey '\(^\s\+\)\@<=exposed:'
+
+" Executable-specifics
+syn region cabalExeR start='^executable\s\@=' end='^\w' transparent keepend contains=cabalExeKey,cabalBuildKey,cabalCondition,cabalOperator,cabalBuildableName
+syn match cabalExeKey '^executable\s\@='
+syn match cabalExeKey '\(^\s\+\)\@<=main-is:'
+
+" Test-specifics
+syn region cabalTestR start='^test-suite\s\@=' end='^\w' transparent keepend contains=cabalTestKey,cabalBuildKey,cabalCondition,cabalOperator,cabalBuildableName
+syn match cabalTestKey '^test-suite\s\@='
+syn match cabalTestKey '\(^\s\+\)\@<=type:'
+syn match cabalTestKey '\(^\s\+\)\@<=main-is:'
+syn match cabalTestKey '\(^\s\+\)\@<=test-module:'
+
+" Benchmark-specifics
+syn region cabalBenchR start='^benchmark\s\@=' end='^\w' transparent keepend contains=cabalBenchKey,cabalBuildKey,cabalCondition,cabalOperator,cabalBuildableName
+syn match cabalBenchKey '^benchmark\s\@='
+syn match cabalBenchKey '\(^\s\+\)\@<=type:'
+syn match cabalBenchKey '\(^\s\+\)\@<=main-is:'
+
+syn match cabalBuildableName '\(^\(^benchmark\|test-suite\|executable\)\s\+\)\@<=\w\+'
+
+" General build info
+syn match cabalBuildKey '\(^\s\+\)\@<=default-language:'
+syn match cabalBuildKey '\(^\s\+\)\@<=build-depends:'
+syn match cabalBuildKey '\(^\s\+\)\@<=other-modules:'
+syn match cabalBuildKey '\(^\s\+\)\@<=hs-source-dirs:'
+syn match cabalBuildKey '\(^\s\+\)\@<=extensions:'
+syn match cabalBuildKey '\(^\s\+\)\@<=build-tools:'
+syn match cabalBuildKey '\(^\s\+\)\@<=buildable:'
+syn match cabalBuildKey '\(^\s\+\)\@<=ghc-options:'
+syn match cabalBuildKey '\(^\s\+\)\@<=ghc-prof-options:'
+syn match cabalBuildKey '\(^\s\+\)\@<=ghc-shared-options:'
+syn match cabalBuildKey '\(^\s\+\)\@<=hugs-options:'
+syn match cabalBuildKey '\(^\s\+\)\@<=nch98-options:'
+syn match cabalBuildKey '\(^\s\+\)\@<=includes:'
+syn match cabalBuildKey '\(^\s\+\)\@<=install-includes:'
+syn match cabalBuildKey '\(^\s\+\)\@<=include-dirs:'
+syn match cabalBuildKey '\(^\s\+\)\@<=c-sources:'
+syn match cabalBuildKey '\(^\s\+\)\@<=extra-libraries:'
+syn match cabalBuildKey '\(^\s\+\)\@<=extra-lib-dirs:'
+syn match cabalBuildKey '\(^\s\+\)\@<=cc-options:'
+syn match cabalBuildKey '\(^\s\+\)\@<=cpp-options:'
+syn match cabalBuildKey '\(^\s\+\)\@<=ld-options:'
+syn match cabalBuildKey '\(^\s\+\)\@<=pkgconfig-depends:'
+syn match cabalBuildKey '\(^\s\+\)\@<=frameworks:'
+
+syn region cabalFlagR start='^flag\s\@=' end='^\w' transparent keepend contains=cabalFlagKey,cabalCondition,cabalFlag
+syn match cabalFlagKey '^flag\s\@='
+syn match cabalFlagKey '\(^\s\+\)\@<=description:'
+syn match cabalFlagKey '\(^\s\+\)\@<=default:'
+syn match cabalFlagKey '\(^\s\+\)\@<=manual:'
+syn match cabalFlag '\(flag\s\+\)\@<=\w\+'
+syn match cabalFlag '\(flag(\)\@<=\w\+)\@='
+
+syn region cabalSourceR start='^source-repository' end='^\w' transparent keepend contains=cabalSourceKey
+syn match cabalSourceKey '^source-repository\s\@='
+syn match cabalSourceKey '\(^\s\+\)\@<=type:'
+syn match cabalSourceKey '\(^\s\+\)\@<=location:'
+syn match cabalSourceKey '\(^\s\+\)\@<=module:'
+syn match cabalSourceKey '\(^\s\+\)\@<=branch:'
+syn match cabalSourceKey '\(^\s\+\)\@<=tag:'
+syn match cabalSourceKey '\(^\s\+\)\@<=subdir:'
+
+syn match cabalCondition '\(^\s\+\)\@<=if\((\|\s\)\@='
+syn match cabalCondition '\(^\s\+\)\@<=else\($\|\s\)\@='
+syn match cabalCondition '\(^\s\+\)\@<=if\((\|\s\)\@='
+syn match cabalCondition '\(^\s\+\)\@<=else\($\|\s\)\@='
+syn match cabalOperator '\W\@<=os\((.\+)\)\@='
+syn match cabalOperator '\W\@<=arch\((.\+)\)\@='
+syn match cabalOperator '\W\@<=impl\((.\+)\)\@='
+syn match cabalOperator '\W\@<=flag\((.\+)\)\@='
+syn match cabalOperator '\(^\s*--.*\)\@<!\(<\|>\|=\|||\|&&\)'
+
+syn match cabalComment '\s\@<=--.*$'
+
+if version >= 508 || !exists('did_cabal_syntax_inits')
+ if version < 508
+ let did_cabal_syntax_inits = 1
+ command -nargs=+ HiLink hi link <args>
+ else
+ command -nargs=+ HiLink hi def link <args>
+ endif
+
+ HiLink cabalBuildableName Structure
+ HiLink cabalFlag Special
+ HiLink cabalComment Comment
+ HiLink cabalCondition Conditional
+ HiLink cabalSourceKey Keyword
+ HiLink cabalOperator Operator
+ HiLink cabalKey Keyword
+ HiLink cabalLibraryKey Keyword
+ HiLink cabalTestKey Keyword
+ HiLink cabalExeKey Keyword
+ HiLink cabalBenchKey Keyword
+ HiLink cabalBuildKey Keyword
+ HiLink cabalFlagKey Keyword
+ HiLink cabalLit Constant
+
+ delcommand HiLink
+endif
+
+let b:current_syntax = 'cabal'
diff --git a/syntax/haskell.vim b/syntax/haskell.vim
index 7ac0fe26..17f48178 100644
--- a/syntax/haskell.vim
+++ b/syntax/haskell.vim
@@ -1,265 +1,115 @@
" Vim syntax file
-"
-" Modification of vims Haskell syntax file:
-" - match types using regular expression
-" - highlight toplevel functions
-" - use "syntax keyword" instead of "syntax match" where appropriate
-" - functions and types in import and module declarations are matched
-" - removed hs_highlight_more_types (just not needed anymore)
-" - enable spell checking in comments and strings only
-" - FFI highlighting
-" - QuasiQuotation
-" - top level Template Haskell slices
-" - PackageImport
-"
-" TODO: find out which vim versions are still supported
-"
-" From Original file:
-" ===================
-"
-" Language: Haskell
-" Maintainer: Haskell Cafe mailinglist <haskell-cafe@haskell.org>
-" Last Change: 2010 Feb 21
-" Original Author: John Williams <jrw@pobox.com>
-"
-" Thanks to Ryan Crumley for suggestions and John Meacham for
-" pointing out bugs. Also thanks to Ian Lynagh and Donald Bruce Stewart
-" for providing the inspiration for the inclusion of the handling
-" of C preprocessor directives, and for pointing out a bug in the
-" end-of-line comment handling.
-"
-" Options-assign a value to these variables to turn the option on:
-"
-" hs_highlight_delimiters - Highlight delimiter characters--users
-" with a light-colored background will
-" probably want to turn this on.
-" hs_highlight_boolean - Treat True and False as keywords.
-" hs_highlight_types - Treat names of primitive types as keywords.
-" hs_highlight_debug - Highlight names of debugging functions.
-" hs_allow_hash_operator - Don't highlight seemingly incorrect C
-" preprocessor directives but assume them to be
-" operators
-"
-"
+" Language: Haskell
+" Author: Tristan Ravitch
+" Maintainer: Tristan Ravitch
+" Version: 0.0.1
if version < 600
- syn clear
-elseif exists("b:current_syntax")
+ syntax clear
+elseif exists('b:current_syntax')
finish
endif
-"syntax sync fromstart "mmhhhh.... is this really ok to do so?
-syntax sync linebreaks=15 minlines=50 maxlines=500
-
-syn match hsSpecialChar contained "\\\([0-9]\+\|o[0-7]\+\|x[0-9a-fA-F]\+\|[\"\\'&\\abfnrtv]\|^[A-Z^_\[\\\]]\)"
-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\)"
-syn match hsSpecialCharError contained "\\&\|'''\+"
-sy region hsString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=hsSpecialChar,@Spell
-sy match hsCharacter "[^a-zA-Z0-9_']'\([^\\]\|\\[^']\+\|\\'\)'"lc=1 contains=hsSpecialChar,hsSpecialCharError
-sy match hsCharacter "^'\([^\\]\|\\[^']\+\|\\'\)'" contains=hsSpecialChar,hsSpecialCharError
-
-" (Qualified) identifiers (no default highlighting)
-syn match ConId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[A-Z][a-zA-Z0-9_']*\>"
-syn match VarId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[a-z][a-zA-Z0-9_']*\>"
-
-" Infix operators--most punctuation characters and any (qualified) identifier
-" enclosed in `backquotes`. An operator starting with : is a constructor,
-" others are variables (e.g. functions).
-syn match hsVarSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[-!#$%&\*\+/<=>\?@\\^|~.][-!#$%&\*\+/<=>\?@\\^|~:.]*"
-syn match hsConSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=:[-!#$%&\*\+./<=>\?@\\^|~:]*"
-syn match hsVarSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[a-z][a-zA-Z0-9_']*`"
-syn match hsConSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[A-Z][a-zA-Z0-9_']*`"
-
-" Toplevel Template Haskell support
-"sy match hsTHTopLevel "^[a-z]\(\(.\&[^=]\)\|\(\n[^a-zA-Z0-9]\)\)*"
-sy match hsTHIDTopLevel "^[a-z]\S*"
-sy match hsTHTopLevel "^\$(\?" nextgroup=hsTHTopLevelName
-sy match hsTHTopLevelName "[a-z]\S*" contained
-
-" Reserved symbols--cannot be overloaded.
-syn match hsDelimiter "(\|)\|\[\|\]\|,\|;\|_\|{\|}"
-
-sy region hsInnerParen start="(" end=")" contained contains=hsInnerParen,hsConSym,hsType,hsVarSym
-sy region hs_InfixOpFunctionName start="^(" end=")\s*[^:`]\(\W\&\S\&[^'\"`()[\]{}@]\)\+"re=s
- \ contained keepend contains=hsInnerParen,hs_HlInfixOp
-
-sy match hs_hlFunctionName "[a-z_]\(\S\&[^,\(\)\[\]]\)*" contained
-sy match hs_FunctionName "^[a-z_]\(\S\&[^,\(\)\[\]]\)*" contained contains=hs_hlFunctionName
-sy match hs_HighliteInfixFunctionName "`[a-z_][^`]*`" contained
-sy match hs_InfixFunctionName "^\S[^=]*`[a-z_][^`]*`"me=e-1 contained contains=hs_HighliteInfixFunctionName,hsType,hsConSym,hsVarSym,hsString,hsCharacter
-sy match hs_HlInfixOp "\(\W\&\S\&[^`(){}'[\]]\)\+" contained contains=hsString
-sy match hs_InfixOpFunctionName "^\(\(\w\|[[\]{}]\)\+\|\(\".*\"\)\|\('.*'\)\)\s*[^:]=*\(\W\&\S\&[^='\"`()[\]{}@]\)\+"
- \ contained contains=hs_HlInfixOp,hsCharacter
-
-sy match hs_OpFunctionName "(\(\W\&[^(),\"]\)\+)" contained
-"sy region hs_Function start="^["'a-z_([{]" end="=\(\s\|\n\|\w\|[([]\)" keepend extend
-sy region hs_Function start="^["'a-zA-Z_([{]\(\(.\&[^=]\)\|\(\n\s\)\)*=" end="\(\s\|\n\|\w\|[([]\)"
- \ contains=hs_OpFunctionName,hs_InfixOpFunctionName,hs_InfixFunctionName,hs_FunctionName,hsType,hsConSym,hsVarSym,hsString,hsCharacter
-
-sy match hs_TypeOp "::"
-sy match hs_DeclareFunction "^[a-z_(]\S*\(\s\|\n\)*::" contains=hs_FunctionName,hs_OpFunctionName,hs_TypeOp
-
-" hi hs_TypeOp guibg=red
-
-" hi hs_InfixOpFunctionName guibg=yellow
-" hi hs_Function guibg=green
-" hi hs_InfixFunctionName guibg=red
-" hi hs_DeclareFunction guibg=red
-
-sy keyword hsStructure data family class where instance default deriving
-sy keyword hsTypedef type newtype
-
-sy keyword hsInfix infix infixl infixr
-sy keyword hsStatement do case of let in
-sy keyword hsConditional if then else
-
-"if exists("hs_highlight_types")
- " Primitive types from the standard prelude and libraries.
- sy match hsType "\<[A-Z]\(\S\&[^,.]\)*\>"
- sy match hsType "()"
-"endif
-
-" Not real keywords, but close.
-if exists("hs_highlight_boolean")
- " Boolean constants from the standard prelude.
- syn keyword hsBoolean True False
-endif
-
-syn region hsPackageString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial contained
-sy match hsModuleName excludenl "\([A-Z]\w*\.\?\)*" contained
-
-sy match hsImport "\<import\>\s\+\(qualified\s\+\)\?\(\<\(\w\|\.\)*\>\)"
- \ contains=hsModuleName,hsImportLabel
- \ nextgroup=hsImportParams,hsImportIllegal skipwhite
-sy keyword hsImportLabel import qualified contained
-
-sy match hsImportIllegal "\w\+" contained
-
-sy keyword hsAsLabel as contained
-sy keyword hsHidingLabel hiding contained
-
-sy match hsImportParams "as\s\+\(\w\+\)" contained
- \ contains=hsModuleName,hsAsLabel
- \ nextgroup=hsImportParams,hsImportIllegal skipwhite
-sy match hsImportParams "hiding" contained
- \ contains=hsHidingLabel
- \ nextgroup=hsImportParams,hsImportIllegal skipwhite
-sy region hsImportParams start="(" end=")" contained
- \ contains=hsBlockComment,hsLineComment, hsType,hsDelimTypeExport,hs_hlFunctionName,hs_OpFunctionName
- \ nextgroup=hsImportIllegal skipwhite
-
-" hi hsImport guibg=red
-"hi hsImportParams guibg=bg
-"hi hsImportIllegal guibg=bg
-"hi hsModuleName guibg=bg
-
-"sy match hsImport "\<import\>\(.\|[^(]\)*\((.*)\)\?"
-" \ contains=hsPackageString,hsImportLabel,hsImportMod,hsModuleName,hsImportList
-"sy keyword hsImportLabel import contained
-"sy keyword hsImportMod as qualified hiding contained
-"sy region hsImportListInner start="(" end=")" contained keepend extend contains=hs_OpFunctionName
-"sy region hsImportList matchgroup=hsImportListParens start="("rs=s+1 end=")"re=e-1
-" \ contained
-" \ keepend extend
-" \ contains=hsType,hsLineComment,hsBlockComment,hs_hlFunctionName,hsImportListInner
-
-
-
-" new module highlighting
-syn region hsDelimTypeExport start="\<[A-Z]\(\S\&[^,.]\)*\>(" end=")" contained
- \ contains=hsType
-
-sy keyword hsExportModuleLabel module contained
-sy match hsExportModule "\<module\>\(\s\|\t\|\n\)*\([A-Z]\w*\.\?\)*" contained contains=hsExportModuleLabel,hsModuleName
-
-sy keyword hsModuleStartLabel module contained
-sy keyword hsModuleWhereLabel where contained
-
-syn match hsModuleStart "^module\(\s\|\n\)*\(\<\(\w\|\.\)*\>\)\(\s\|\n\)*"
- \ contains=hsModuleStartLabel,hsModuleName
- \ nextgroup=hsModuleCommentA,hsModuleExports,hsModuleWhereLabel
-
-syn region hsModuleCommentA start="{-" end="-}"
- \ contains=hsModuleCommentA,hsCommentTodo,@Spell contained
- \ nextgroup=hsModuleCommentA,hsModuleExports,hsModuleWhereLabel skipwhite skipnl
-
-syn match hsModuleCommentA "--.*\n"
- \ contains=hsCommentTodo,@Spell contained
- \ nextgroup=hsModuleCommentA,hsModuleExports,hsModuleWhereLabel skipwhite skipnl
-
-syn region hsModuleExports start="(" end=")" contained
- \ nextgroup=hsModuleCommentB,hsModuleWhereLabel skipwhite skipnl
- \ contains=hsBlockComment,hsLineComment,hsType,hsDelimTypeExport,hs_hlFunctionName,hs_OpFunctionName,hsExportModule
-
-syn match hsModuleCommentB "--.*\n"
- \ contains=hsCommentTodo,@Spell contained
- \ nextgroup=hsModuleCommentB,hsModuleWhereLabel skipwhite skipnl
-
-syn region hsModuleCommentB start="{-" end="-}"
- \ contains=hsModuleCommentB,hsCommentTodo,@Spell contained
- \ nextgroup=hsModuleCommentB,hsModuleWhereLabel skipwhite skipnl
-" end module highlighting
-
-" FFI support
-sy keyword hsFFIForeign foreign contained
-"sy keyword hsFFIImportExport import export contained
-sy keyword hsFFIImportExport export contained
-sy keyword hsFFICallConvention ccall stdcall contained
-sy keyword hsFFISafety safe unsafe contained
-sy region hsFFIString start=+"+ skip=+\\\\\|\\"+ end=+"+ contained contains=hsSpecialChar
-sy match hsFFI excludenl "\<foreign\>\(.\&[^\"]\)*\"\(.\)*\"\(\s\|\n\)*\(.\)*::"
- \ keepend
- \ contains=hsFFIForeign,hsFFIImportExport,hsFFICallConvention,hsFFISafety,hsFFIString,hs_OpFunctionName,hs_hlFunctionName
-
-
-sy match hsNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>"
-sy match hsFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
-
-" Comments
-sy keyword hsCommentTodo TODO FIXME XXX TBD contained
-sy match hsLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=hsCommentTodo,@Spell
-sy region hsBlockComment start="{-" end="-}" contains=hsBlockComment,hsCommentTodo,@Spell
-sy region hsPragma start="{-#" end="#-}"
-
-" QuasiQuotation
-sy region hsQQ start="\[\$" end="|\]"me=e-2 keepend contains=hsQQVarID,hsQQContent nextgroup=hsQQEnd
-sy region hsQQNew start="\[\(.\&[^|]\&\S\)*|" end="|\]"me=e-2 keepend contains=hsQQVarIDNew,hsQQContent nextgroup=hsQQEnd
-sy match hsQQContent ".*" contained
-sy match hsQQEnd "|\]" contained
-sy match hsQQVarID "\[\$\(.\&[^|]\)*|" contained
-sy match hsQQVarIDNew "\[\(.\&[^|]\)*|" contained
-
-if exists("hs_highlight_debug")
- " Debugging functions from the standard prelude.
- syn keyword hsDebug undefined error trace
-endif
-
-
-" C Preprocessor directives. Shamelessly ripped from c.vim and trimmed
-" First, see whether to flag directive-like lines or not
-if (!exists("hs_allow_hash_operator"))
- syn match cError display "^\s*\(%:\|#\).*$"
-endif
-" Accept %: for # (C99)
-syn region cPreCondit start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=cComment,cCppString,cCommentError
-syn match cPreCondit display "^\s*\(%:\|#\)\s*\(else\|endif\)\>"
-syn region cCppOut start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2
-syn region cCppOut2 contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=cCppSkip
-syn region cCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cCppSkip
-syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
-syn match cIncluded display contained "<[^>]*>"
-syn match cInclude display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
-syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cCppOut,cCppOut2,cCppSkip,cCommentStartError
-syn region cDefine matchgroup=cPreCondit start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$"
-syn region cPreProc matchgroup=cPreCondit start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend
-
-syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=cCommentStartError,cSpaceError contained
-syntax match cCommentError display "\*/" contained
-syntax match cCommentStartError display "/\*"me=e-1 contained
-syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial contained
-
-
-if version >= 508 || !exists("did_hs_syntax_inits")
+syn sync minlines=50 maxlines=200
+
+" These basic lexical definitions are taken from the orignal haskell syntax
+" description from vim 7.3.
+syn match hsSpecialChar contained "\\\([0-9]\+\|o[0-7]\+\|x[0-9a-fA-F]\+\|[\"\\'&\\abfnrtv]\|^[A-Z^_\[\\\]]\)"
+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\)"
+syn match hsSpecialCharError contained "\\&\|'''\+"
+syn region hsString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=hsSpecialChar
+syn match hsCharacter "[^a-zA-Z0-9_']'\([^\\]\|\\[^']\+\|\\'\)'"lc=1 contains=hsSpecialChar,hsSpecialCharError
+syn match hsCharacter "^'\([^\\]\|\\[^']\+\|\\'\)'" contains=hsSpecialChar,hsSpecialCharError
+syn match hsNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>"
+syn match hsFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
+
+" This case matches the names of types and constructors: names beginning with
+" a capital letter. Note that this also handles the case of @M.lookup@ where
+" M is a qualified import. There is a big negative lookbehind assertion here
+" so that we don't highlight import and module statements oddly.
+syn match hsTypeName "\(^import\s.*\|^module\s.*\)\@<!\([^a-zA-Z0-9]\)\@<=[A-Z][a-zA-Z0-9_]*"
+" Also make unit and the empty list easy to spot - they are constructors too.
+syn match hsTypeName "()"
+syn match hsTypeName "\[\]"
+
+" These are keywords that are only highlighted if they are in comments.
+syn keyword hsFIXME contained FIXME TODO XXX BUG NOTE
+
+" Comment stuff
+syn region hsPragma start='{-#' end='#-}'
+syn region hsBlockComment start='{-' end='-}' fold contains=hsFIXME,hsBlockComment
+" FIXME: haddock block comments should be able to contain hsBlockComments, but
+" it doesn't seem to work at the moment.
+syn region hsHaddockComment start='{-|' end='-}' contains=hsFIXME
+syn match hsLineComment "--.*$" contains=hsFIXME
+" Line-based haddock comments are trickier - they continue until
+" the next line that isn't part of the same block of comments.
+syn region hsHaddockComment start='-- |' end='^\(\s*--\)\@!' contains=hsFIXME
+syn region hsHaddockComment start='-- \$\w\+' end='^\(\s*--\)\@!' contains=hsFIXME
+syn region hsHaddockComment start='-- ^' end='^\(\s*--\)\@!' contains=hsFIXME
+" Haddock sections for import lists
+syn match hsHaddockSection '-- \*.*$'
+" Named documentation chunks (also for import lists)
+syn match hsHaddockSection '-- \$.*$'
+
+
+" Keywords appearing in expressions, plus a few top-level keywords
+syn keyword hsKeyword do let in _ where
+syn keyword hsKeyword infix infixl infixr
+syn keyword hsKeyword forall foreign
+syn match hsKeyword '\(^\(data\|type\)\s\+\)\@<=family\(\W\)\@='
+
+" Vim has a special syntax category for conditionals, so here are all of the
+" haskell conditionals. These are just keywords with a slightly more flexible
+" coloring.
+syn keyword hsConditional case of if then else
+
+" We define a region for module NNNN (...) where so that haddock section
+" headers (-- *) can be highlighted specially only within this context.
+syn region hsModuleHeader start="^module\s" end="where" contains=hsHaddockSection keepend fold transparent
+" Treat Module imports as the #include category; it maps reasonably well
+syn keyword hsImport import qualified as hiding module
+
+syn keyword hsTypeDecls class instance data newtype type deriving default
+" FIXME: Maybe we can do something fancy for data/type families? 'family' is
+" only a keyword if it follows data/type...
+
+" This is uglier than I'd like. We want to let '-' participate in operators,
+" but we can't let it match '--' because that interferes with comments. Hacks
+" for now - just include some common operators with '-'.
+syn match hsOperator "<-\|->\|-->\|-\(-\)\@!\|[%\~\&\*/\$\^|@:+<!>=#!\?]\+"
+" A bare . is an operator (but not surrounded by alnum chars)
+syn match hsOperator "\s\@<=\.\s\@="
+" . is also an operator if adjacent to some other operator char
+syn match hsOperator "[%\~\&\*\$\^|@:+<!>=#!\?]\+\.[%\~\&\*\$\^|@:+<\.!>=#!\?]*"
+syn match hsOperator "[%\~\&\*\$\^|@:+<!>=#!\?]*\.[%\~\&\*\$\^|@:+\.<!>=#!\?]\+"
+" Include support for infix functions as operators
+syn match hsOperator "`[a-zA-Z0-9\.]\+`"
+
+" Highlight function/value names in type signatures. Looks ahead to find a ::
+" after a name. This allows whitespace before the name so that it can match
+" in a 'where,' but it won't match local type annotations on random little
+" things.
+syn match hsFunctionList "^\s*\([a-z][a-zA-Z0-9']*[[:space:]\n,]\+\)*[a-z][a-zA-Z0-9']*[[:space:]\n]*::" contains=hsFunction
+syn match hsFunction "\s*[a-z][a-zA-Z0-9']*[[:space:]\n]*\(::\|,\)\@=" contained
+" Also support the style where the first where binding is on the same line as
+" the where keyword.
+syn match hsFunction "\(^\s\+where\s\+\)\@<=[a-z][a-zA-Z0-9']*\(\s*::\)\@="
+
+" FIXME Ignoring proc for now, also mdo and rec
+
+" Give undefined a bit of special treatment
+syn keyword hsScary undefined
+
+" C Preprocessor stuff
+syn match hsCPP '\(^\s*\)\@<=#\(warning\|pragma\|error\)\W\@='
+syn match hsCPPCond '\(^\s*\)\@<=#\(if\|ifdef\|elif\)\W\@='
+syn match hsCPPCond '\(^\s*\)\@<=#\(endif\|else\)\(\s*$\|\W\)\@='
+syn match hsCPPInclude '\(^\s*\)\@<=#include\W\@='
+syn match hsCPPDefine '\(^\s*\)\@<=#define\W\@='
+syn match hsCPPDefined '\(^\s*.*\W\)\@<=defined(\w\+)'
+
+if version >= 508 || !exists('did_hs_syntax_inits')
if version < 508
let did_hs_syntax_inits = 1
command -nargs=+ HiLink hi link <args>
@@ -267,91 +117,42 @@ if version >= 508 || !exists("did_hs_syntax_inits")
command -nargs=+ HiLink hi def link <args>
endif
- HiLink hs_hlFunctionName Function
- HiLink hs_HighliteInfixFunctionName Function
- HiLink hs_HlInfixOp Function
- HiLink hs_OpFunctionName Function
- HiLink hsTypedef Typedef
- HiLink hsVarSym hsOperator
- HiLink hsConSym hsOperator
- if exists("hs_highlight_delimiters")
- " Some people find this highlighting distracting.
- HiLink hsDelimiter Delimiter
- endif
-
- HiLink hsModuleStartLabel Structure
- HiLink hsExportModuleLabel Keyword
- HiLink hsModuleWhereLabel Structure
- HiLink hsModuleName Normal
-
- HiLink hsImportIllegal Error
- HiLink hsAsLabel hsImportLabel
- HiLink hsHidingLabel hsImportLabel
- HiLink hsImportLabel Include
- HiLink hsImportMod Include
- HiLink hsPackageString hsString
-
- HiLink hsOperator Operator
+ " CPP
+ HiLink hsCPP PreProc
+ HiLink hsCPPCond PreCondit
+ HiLink hsCPPInclude Include
+ HiLink hsCPPDefine Define
+ HiLink hsCPPDefined PreProc
- HiLink hsInfix Keyword
- HiLink hsStructure Structure
- HiLink hsStatement Statement
- HiLink hsConditional Conditional
+ " Comments
+ HiLink hsLineComment Comment
+ HiLink hsBlockComment Comment
+ HiLink hsPragma Comment
+ HiLink hsHaddockComment SpecialComment
+ HiLink hsHaddockSection SpecialComment
- HiLink hsSpecialCharError Error
- HiLink hsSpecialChar SpecialChar
- HiLink hsString String
- HiLink hsFFIString String
- HiLink hsCharacter Character
- HiLink hsNumber Number
- HiLink hsFloat Float
-
- HiLink hsLiterateComment hsComment
- HiLink hsBlockComment hsComment
- HiLink hsLineComment hsComment
- HiLink hsModuleCommentA hsComment
- HiLink hsModuleCommentB hsComment
- HiLink hsComment Comment
- HiLink hsCommentTodo Todo
- HiLink hsPragma SpecialComment
- HiLink hsBoolean Boolean
-
- if exists("hs_highlight_types")
- HiLink hsDelimTypeExport hsType
- HiLink hsType Type
- endif
+ HiLink hsKeyword Keyword
+ HiLink hsConditional Conditional
+ HiLink hsImport Include
+ HiLink hsTypeDecls Keyword
- HiLink hsDebug Debug
+ HiLink hsFIXME Todo
- HiLink hs_TypeOp hsOperator
+ HiLink hsOperator Operator
- HiLink cCppString hsString
- HiLink cCommentStart hsComment
- HiLink cCommentError hsError
- HiLink cCommentStartError hsError
- HiLink cInclude Include
- HiLink cPreProc PreProc
- HiLink cDefine Macro
- HiLink cIncluded hsString
- HiLink cError Error
- HiLink cPreCondit PreCondit
- HiLink cComment Comment
- HiLink cCppSkip cCppOut
- HiLink cCppOut2 cCppOut
- HiLink cCppOut Comment
+ HiLink hsModuleQualifier StorageClass
- HiLink hsFFIForeign Keyword
- HiLink hsFFIImportExport Structure
- HiLink hsFFICallConvention Keyword
- HiLink hsFFISafety Keyword
+ HiLink hsFunction Function
+ HiLink hsTypeName Type
- HiLink hsTHIDTopLevel Macro
- HiLink hsTHTopLevelName Macro
+ " Literals
+ HiLink hsSpecialChar SpecialChar
+ HiLink hsFloat Float
+ HiLink hsNumber Number
+ HiLink hsCharacter Character
+ HiLink hsString String
- HiLink hsQQVarID Keyword
- HiLink hsQQVarIDNew Keyword
- HiLink hsQQEnd Keyword
- HiLink hsQQContent String
+ HiLink hsScary Todo
delcommand HiLink
endif