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 / vim54rt.sit / runtime / syntax / ptcap.vim < prev    next >
Encoding:
Text File  |  1999-08-14  |  3.7 KB  |  90 lines  |  [TEXT/ALFA]

  1. " Vim syntax file
  2. " Language:    printcap/termcap database
  3. " Maintainer:    Haakon Riiser <hakonrk@fys.uio.no>
  4. " Last change:    1998 Dec 5
  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.  
  36. " A backslash at the end of a line will suppress the newline
  37. syn match ptcapLineCont        "\\$" contained
  38.  
  39. " A number follows the same rules as an integer in C
  40. syn match ptcapNumber        "#\(+\|-\)\=\d\+"lc=1 contained
  41. syn match ptcapNumberError  "#\d*[^[:digit:]:\\]"lc=1 contained
  42. syn match ptcapNumber        "#0x\x\{1,8}"lc=1 contained
  43. syn match ptcapNumberError  "#0x\X"me=e-1,lc=1 contained
  44. syn match ptcapNumberError  "#0x\x\{9}"lc=1 contained
  45. syn match ptcapNumberError  "#0x\x*[^[:xdigit:]:\\]"lc=1 contained
  46.  
  47. " The `@' operator clears a flag (i.e., sets it to zero)
  48. " The `#' operator assigns a following number to the flag
  49. " The `=' operator assigns a string to the preceding flag
  50. syn match ptcapOperator        "[@#=]" contained
  51.  
  52. " Some terminal capabilites have special names like `#5' and `@1', and we
  53. " need special rules to match these properly
  54. syn match ptcapSpecialCap   "\W[#@]\d" contains=ptcapDelimiter contained
  55.  
  56. " If editing a termcap file, an entry in the database is terminated by
  57. " a (non-escaped) newline.  Otherwise, it is terminated by a line which
  58. " does not start with a colon (:)
  59. if bufname("%") =~ ".*termcap.*"
  60.     syn region ptcapEntry   start="^\s*[^[:space:]:]" end="[^\\]\(\\\\\)*$" end="^$" contains=ptcapNames,ptcapField,ptcapLeadBlank keepend
  61. else
  62.     syn region ptcapEntry   start="^\s*[^[:space:]:]"me=e-1 end="^\s*[^[:space:]:#]"me=e-1 contains=ptcapNames,ptcapField,ptcapLeadBlank,ptcapComment
  63. endif
  64. syn region ptcapNames        start="^\s*[^[:space:]:]" skip="[^\\]\(\\\\\)*\\:" end=":"me=e-1 contains=ptcapDelimiter,ptcapEscapedChar,ptcapLineCont,ptcapLeadBlank,ptcapComment keepend contained
  65. syn region ptcapField        start=":" skip="[^\\]\(\\\\\)*\\$" end="[^\\]\(\\\\\)*:"me=e-1 end="$" contains=ptcapDelimiter,ptcapString,ptcapNumber,ptcapNumberError,ptcapOperator,ptcapLineCont,ptcapSpecialCap,ptcapLeadBlank,ptcapComment keepend contained
  66. syn region ptcapString        matchgroup=ptcapOperator start="=" skip="[^\\]\(\\\\\)*\\:" matchgroup=ptcapDelimiter end=":"me=e-1 matchgroup=NONE end="[^\\]\(\\\\\)*[^\\]$" end="^$" contains=ptcapEscapedChar,ptcapLineCont keepend contained
  67. syn region ptcapComment        start="^\s*#" end="$" contains=ptcapLeadBlank
  68.  
  69. if !exists("did_ptcap_syntax_inits")
  70.     let did_ptcap_syntax_inits = 1
  71.     hi link ptcapComment    Comment
  72.     hi link ptcapDelimiter    Delimiter
  73.     hi link ptcapEntry        Todo
  74.     hi link ptcapError        Error
  75.     hi link ptcapEscapedChar    SpecialChar
  76.     hi link ptcapField        Type
  77.     hi link ptcapLeadBlank    NONE
  78.     hi link ptcapLineCont    Special
  79.     hi link ptcapNames        Label
  80.     hi link ptcapNumber        NONE
  81.     hi link ptcapNumberError    Error
  82.     hi link ptcapOperator    Operator
  83.     hi link ptcapSpecialCap    Type
  84.     hi link ptcapString        NONE
  85. endif
  86.  
  87. let b:current_syntax = "ptcap"
  88.  
  89. " vim: sts=4 sw=4 ts=8
  90.