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 / runtime / dos / syntax / ptcap.vim < prev    next >
Encoding:
Text File  |  2010-08-15  |  4.5 KB  |  108 lines

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