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