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 / ptcap.vim < prev    next >
Encoding:
Text File  |  1999-09-25  |  4.0 KB  |  94 lines  |  [TEXT/VIM!]

  1. " Vim syntax file
  2. " Language:    printcap/termcap database
  3. " Maintainer:    Haakon Riiser <hakonrk@fys.uio.no>
  4. " Last change:    1999 Sep 14
  5.  
  6. " Clear old syntax defs
  7. syn clear
  8.  
  9. " Since I only highlight based on the structure of the databases, not
  10. " specific keywords, case sensitivity isn't required
  11. syn case ignore
  12.  
  13. " Since everything that is not caught by the syntax patterns is assumed
  14. " to be an error, we start parsing 20 lines up, unless something else
  15. " is specified
  16. if exists("ptcap_minlines")
  17.     exe "syn sync lines=".ptcap_minlines
  18. else
  19.     syn sync lines=20
  20. endif
  21.  
  22. " Highlight everything that isn't caught by the rules as errors,
  23. " except blank lines
  24. syn match ptcapError        "^.*\S.*$"
  25.  
  26. syn match ptcapLeadBlank    "^\s\+" contained
  27.  
  28. " `:' and `|' are delimiters for fields and names, and should not be
  29. " highlighted.    Hence, they are linked to `NONE'
  30. syn match ptcapDelimiter    "[:|]" contained
  31.  
  32. " Escaped characters receive special highlighting
  33. syn match ptcapEscapedChar  "\\." contained
  34. syn match ptcapEscapedChar  "\^." contained
  35. syn match ptcapEscapedChar  "\\\o\{3}" contained
  36.  
  37. " A backslash at the end of a line will suppress the newline
  38. syn match ptcapLineCont        "\\$" contained
  39.  
  40. " A number follows the same rules as an integer in C
  41. syn match ptcapNumber        "#\(+\|-\)\=\d\+"lc=1 contained
  42. syn match ptcapNumberError  "#\d*[^[:digit:]:\\]"lc=1 contained
  43. syn match ptcapNumber        "#0x\x\{1,8}"lc=1 contained
  44. syn match ptcapNumberError  "#0x\X"me=e-1,lc=1 contained
  45. syn match ptcapNumberError  "#0x\x\{9}"lc=1 contained
  46. syn match ptcapNumberError  "#0x\x*[^[:xdigit:]:\\]"lc=1 contained
  47.  
  48. " The `@' operator clears a flag (i.e., sets it to zero)
  49. " The `#' operator assigns a following number to the flag
  50. " The `=' operator assigns a string to the preceding flag
  51. syn match ptcapOperator        "[@#=]" contained
  52.  
  53. " Some terminal capabilites have special names like `#5' and `@1', and we
  54. " need special rules to match these properly
  55. syn match ptcapSpecialCap   "\W[#@]\d" contains=ptcapDelimiter contained
  56.  
  57. " If editing a termcap file, an entry in the database is terminated by
  58. " a (non-escaped) newline.  Otherwise, it is terminated by a line which
  59. " does not start with a colon (:)
  60. if bufname("%") =~ ".*termcap.*"
  61.     syn region ptcapEntry   start="^\s*[^[:space:]:]" end="[^\\]\(\\\\\)*$" end="^$" contains=ptcapNames,ptcapField,ptcapLeadBlank keepend
  62. else
  63.     syn region ptcapEntry   start="^\s*[^[:space:]:]"me=e-1 end="^\s*[^[:space:]:#]"me=e-1 contains=ptcapNames,ptcapField,ptcapLeadBlank,ptcapComment
  64. endif
  65. syn region ptcapNames        start="^\s*[^[:space:]:]" skip="[^\\]\(\\\\\)*\\:" end=":"me=e-1 contains=ptcapDelimiter,ptcapEscapedChar,ptcapLineCont,ptcapLeadBlank,ptcapComment keepend contained
  66. syn region ptcapField        start=":" skip="[^\\]\(\\\\\)*\\$" end="[^\\]\(\\\\\)*:"me=e-1 end="$" contains=ptcapDelimiter,ptcapString,ptcapNumber,ptcapNumberError,ptcapOperator,ptcapLineCont,ptcapSpecialCap,ptcapLeadBlank,ptcapComment keepend contained
  67. syn region ptcapString        matchgroup=ptcapOperator start="=" skip="[^\\]\(\\\\\)*\\:" matchgroup=ptcapDelimiter end=":"me=e-1 matchgroup=NONE end="[^\\]\(\\\\\)*[^\\]$" end="^$" contains=ptcapEscapedChar,ptcapLineCont keepend contained
  68. syn region ptcapComment        start="^\s*#" end="$" contains=ptcapLeadBlank
  69.  
  70. if !exists("did_ptcap_syntax_inits")
  71.     let did_ptcap_syntax_inits = 1
  72.     hi link ptcapComment    Comment
  73.     hi link ptcapDelimiter    Delimiter
  74.     " The highlighting of "ptcapEntry" should always be overridden by
  75.     " its contents, so I use Todo highlighting to indicate that there
  76.     " is work to be done with the syntax file if you can see it :-)
  77.     hi link ptcapEntry        Todo
  78.     hi link ptcapError        Error
  79.     hi link ptcapEscapedChar    SpecialChar
  80.     hi link ptcapField        Type
  81.     hi link ptcapLeadBlank    NONE
  82.     hi link ptcapLineCont    Special
  83.     hi link ptcapNames        Label
  84.     hi link ptcapNumber        NONE
  85.     hi link ptcapNumberError    Error
  86.     hi link ptcapOperator    Operator
  87.     hi link ptcapSpecialCap    Type
  88.     hi link ptcapString        NONE
  89. endif
  90.  
  91. let b:current_syntax = "ptcap"
  92.  
  93. " vim: sts=4 sw=4 ts=8
  94.