home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / mac / vim55rt.sit / runtime / syntax / haskell.vim < prev    next >
Encoding:
Text File  |  1999-09-25  |  6.0 KB  |  135 lines  |  [TEXT/VIM!]

  1. " Vim syntax file
  2. " Language:    Haskell
  3. " Maintainer:    John Williams <jrw@pobox.com>
  4. " Last change:    1999 May 8
  5. " Thanks to Ryan Crumley for suggestions and John Meacham for
  6. " pointing out bugs.
  7. "
  8. " Options-assign a value to these variables to turn the option on:
  9. "
  10. " hs_highlight_delimiters - Highlight delimiter characters--users
  11. "                           with a light-colored background will
  12. "                           probably want to turn this on.
  13. " hs_highlight_boolean - Treat True and False as keywords.
  14. " hs_highlight_types - Treat names of primitive types as keywords.
  15. " hs_highlight_more_types - Treat names of other common types as keywords.
  16. " hs_highlight_debug - Highlight names of debugging functions.
  17.  
  18. " Remove any old syntax stuff hanging around
  19. syn clear
  20.  
  21. " (Qualified) identifiers (no default highlighting)
  22. syn match ConId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[A-Z][a-zA-Z0-9_']*\>"
  23. syn match VarId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[a-z][a-zA-Z0-9_']*\>"
  24.  
  25. " Infix operators--most punctuation characters and any (qualified) identifier
  26. " enclosed in `backquotes`. An operator starting with : is a constructor,
  27. " others are variables (e.g. functions).
  28. syn match hsVarSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[-!#$%&\*\+/<=>\?@\\^|~.][-!#$%&\*\+/<=>\?@\\^|~:.]*"
  29. syn match hsConSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=:[-!#$%&\*\+./<=>\?@\\^|~:]*"
  30. syn match hsVarSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[a-z][a-zA-Z0-9_']*`"
  31. syn match hsConSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[A-Z][a-zA-Z0-9_']*`"
  32.  
  33. " Reserved symbols--cannot be overloaded.
  34. syn match hsDelimiter  "(\|)\|\[\|\]\|,\|;\|_\|{\|}"
  35.  
  36. " Strings and constants
  37. syn match   hsSpecialChar      contained "\\\([0-9]\+\|o[0-7]\+\|x[0-9a-fA-F]\+\|[\"\\'&\\abfnrtv]\|^[A-Z^_\[\\\]]\)"
  38. 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\)"
  39. syn match   hsSpecialCharError contained "\\&\|'''\+"
  40. syn region  hsString           start=+"+  skip=+\\\\\|\\"+  end=+"+  contains=hsSpecialChar
  41. syn match   hsCharacter        "[^a-zA-Z0-9_']'\([^\\]\|\\[^']\+\|\\'\)'"lc=1 contains=hsSpecialChar,hsSpecialCharError
  42. syn match   hsCharacter        "^'\([^\\]\|\\[^']\+\|\\'\)'" contains=hsSpecialChar,hsSpecialCharError
  43. syn match   hsNumber           "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>"
  44. syn match   hsFloat            "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
  45.  
  46. " Keyword definitions. These must be patters instead of keywords
  47. " because otherwise they would match as keywords at the start of a
  48. " "literate" comment (see lhs.vim).
  49. syn match hsModule          "\<module\>"
  50. syn match hsImport          "\<import\>.*"he=s+6 contains=hsImportMod
  51. syn match hsImportMod       contained "\<\(as\|qualified\|hiding\)\>"
  52. syn match hsInfix           "\<\(infix\|infixl\|infixr\)\>"
  53. syn match hsStructure       "\<\(class\|data\|deriving\|instance\|default\|where\)\>"
  54. syn match hsTypedef         "\<\(type\|newtype\)\>"
  55. syn match hsStatement       "\<\(do\|case\|of\|let\|in\)\>"
  56. syn match hsConditional     "\<\(if\|then\|else\)\>"
  57.  
  58. " Not real keywords, but close.
  59. if exists("hs_highlight_boolean")
  60.   " Boolean constants from the standard prelude.
  61.   syn match hsBoolean "\<\(True\|False\)\>"
  62. endif
  63. if exists("hs_highlight_types")
  64.   " Primitive types from the standard prelude and libraries.
  65.   syn match hsType "\<\(Int\|Integer\|Char\|Bool\|Float\|Double\|IO\|Void\|Addr\|Array\|String\)\>"
  66. endif
  67. if exists("hs_highlight_more_types")
  68.   " Types from the standard prelude libraries.
  69.   syn match hsType "\<\(Maybe\|Either\|Ratio\|Complex\|Ordering\|IOError\|IOResult\|ExitCode\)\>"
  70.   syn match hsMaybe    "\<Nothing\>"
  71.   syn match hsExitCode "\<\(ExitSuccess\)\>"
  72.   syn match hsOrdering "\<\(GT\|LT\|EQ\)\>"
  73. endif
  74. if exists("hs_highlight_debug")
  75.   " Debugging functions from the standard prelude.
  76.   syn match hsDebug "\<\(undefined\|error\|trace\)\>"
  77. endif
  78.  
  79.  
  80. " Comments
  81. syn match   hsLineComment      "--.*"
  82. syn region  hsBlockComment     start="{-"  end="-}" contains=hsBlockComment
  83. syn region  hsPragma           start="{-#" end="#-}"
  84.  
  85. " Literate comments--any line not starting with '>' is a comment.
  86. if exists("b:hs_literate_comments")
  87.   syn region  hsLiterateComment   start="^" end="^>"
  88. endif
  89.  
  90. if !exists("hs_minlines")
  91.   let hs_minlines = 50
  92. endif
  93. exec "syn sync lines=" . hs_minlines
  94.  
  95. if !exists("did_hs_syntax_inits")
  96.   let did_hs_syntax_inits = 1
  97.   hi link hsModule                        hsStructure
  98.   hi link hsImport                        Include
  99.   hi link hsImportMod                     hsImport
  100.   hi link hsInfix                         PreProc
  101.   hi link hsStructure                     Structure
  102.   hi link hsStatement                     Statement
  103.   hi link hsConditional                   Conditional
  104.   hi link hsSpecialChar                   SpecialChar
  105.   hi link hsTypedef                       Typedef
  106.   hi link hsVarSym                        hsOperator
  107.   hi link hsConSym                        hsOperator
  108.   hi link hsOperator                      Operator
  109.   if exists("hs_highlight_delimiters")
  110.     " Some people find this highlighting distracting.
  111.     hi link hsDelimiter                   Delimiter
  112.   endif
  113.   hi link hsSpecialCharError              Error
  114.   hi link hsString                        String
  115.   hi link hsCharacter                     Character
  116.   hi link hsNumber                        Number
  117.   hi link hsFloat                         Float
  118.   hi link hsConditional                   Conditional
  119.   hi link hsLiterateComment               hsComment
  120.   hi link hsBlockComment                  hsComment
  121.   hi link hsLineComment                   hsComment
  122.   hi link hsComment                       Comment
  123.   hi link hsPragma                        SpecialComment
  124.   hi link hsBoolean                       Boolean
  125.   hi link hsType                          Type
  126.   hi link hsMaybe                         hsEnumConst
  127.   hi link hsOrdering                      hsEnumConst
  128.   hi link hsEnumConst                     Constant
  129.   hi link hsDebug                         Debug
  130. endif
  131.  
  132. let b:current_syntax = "haskell"
  133.  
  134. " vim: ts=8
  135.