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 / patches / vim-6.0-sh.vim < prev   
Encoding:
Text File  |  2001-09-26  |  20.6 KB  |  408 lines

  1. " Vim syntax file
  2. " Language:        shell (sh) Korn shell (ksh) bash (sh)
  3. " Maintainer:        Dr. Charles E. Campbell, Jr. <Charles.E.Campbell.1@gsfc.nasa.gov>
  4. " Previous Maintainer:    Lennart Schultz <Lennart.Schultz@ecmwf.int>
  5. " Last Change:    September 26, 2001
  6. " Version: 27
  7. "
  8. " Using the following VIM variables:
  9. " b:is_kornshell               if defined, enhance with kornshell syntax
  10. " b:is_bash                    if defined, enhance with bash syntax
  11. "   is_kornshell               if neither b:is_kornshell or b:is_bash is
  12. "                                 defined, then if is_kornshell is set
  13. "                                 b:is_kornshell is default
  14. "   is_bash                    if none of the previous three variables are
  15. "                                 defined, then if is_bash is set b:is_bash is default
  16. "
  17. " This file includes many ideas from â•”ric Brunet (eric.brunet@ens.fr)
  18.  
  19. " For version 5.x: Clear all syntax items
  20. " For version 6.x: Quit when a syntax file was already loaded
  21. if version < 600
  22.   syntax clear
  23. elseif exists("b:current_syntax")
  24.   finish
  25. endif
  26.  
  27. " b:is_sh is set when "#! /bin/sh" is found;
  28. " However, it often is just a masquerade by bash or kornshell.
  29. " So, when the user to set "is_bash" or "is_kornshell",
  30. " a b:is_sh is converted into b:is_bash/b:is_kornshell,
  31. " respectively.
  32. if !exists("b:is_kornshell") && !exists("b:is_bash")
  33.   if exists("is_kornshell")
  34.     let b:is_kornshell= 1
  35.     if exists("b:is_sh")
  36.       unlet b:is_sh
  37.     endif
  38.   elseif exists("is_bash")
  39.     let b:is_bash= 1
  40.     if exists("b:is_sh")
  41.       unlet b:is_sh
  42.     endif
  43.   else
  44.     let b:is_sh= 1
  45.   endif
  46. endif
  47.  
  48. " sh syntax is case sensitive
  49. syn case match
  50.  
  51. " This one is needed INSIDE a CommandSub, so that `echo bla` be correct
  52. syn cluster shEchoList    contains=shNumber,shArithmetic,shCommandSub,shSinglequote,shDeref,shSpecialVar,shSpecial,shOperator,shDoubleQuote,shCharClass,shPosnParm
  53. syn region shEcho matchgroup=shStatement start="\<echo\>"  skip="\\$" matchgroup=shOperator end="$" matchgroup=NONE end="[<>;&|()]"me=e-1 end="\d[<>]"me=e-2 end="#"me=e-1 contains=@shEchoList
  54. syn region shEcho matchgroup=shStatement start="\<print\>" skip="\\$" matchgroup=shOperator end="$" matchgroup=NONE end="[<>;&|()]"me=e-1 end="\d[<>]"me=e-2 end="#"me=e-1 contains=@shEchoList
  55.  
  56. " This must be after the strings, so that bla \" be correct
  57. syn region shEmbeddedEcho contained matchgroup=shStatement start="\<print\>" skip="\\$" matchgroup=shOperator end="$" matchgroup=NONE end="[<>;&|`)]"me=e-1 end="\d[<>]"me=e-2 end="#"me=e-1 contains=shNumber,shSinglequote,shDeref,shSpecialVar,shSpecial,shOperator,shDoubleQuote,shCharClass
  58.  
  59. " Error Codes
  60. " ===========
  61. syn match   shDoError "\<done\>"
  62. syn match   shIfError "\<fi\>"
  63. syn match   shInError "\<in\>"
  64. syn match   shCaseError ";;"
  65. syn match   shEsacError "\<esac\>"
  66. syn match   shCurlyError "}"
  67. syn match   shParenError ")"
  68. if exists("b:is_kornshell")
  69.  syn match     shDTestError "]]"
  70. endif
  71. syn match     shTestError "]"
  72.  
  73. " Options interceptor
  74. syn match   shOption  "\s[\-+][a-zA-Z0-9]\+\>"ms=s+1
  75. syn match   shOption  "\s--\S\+"ms=s+1
  76.  
  77. " error clusters:
  78. "================
  79. syn cluster shErrorList    contains=shCaseError,shCurlyError,shDTestError,shDerefError,shDoError,shEsacError,shIfError,shInError,shParenError,shTestError
  80. syn cluster shErrorFuncList    contains=shDerefError
  81. syn cluster shErrorLoopList    contains=shCaseError,shDTestError,shDerefError,shDoError,shInError,shParenError,shTestError
  82. syn cluster shErrorCaseList    contains=shCaseError,shDerefError,shDTestError,shDoError,shInError,shParenError,shTestError
  83. syn cluster shErrorColonList    contains=shDerefError
  84. syn cluster shErrorNoneList    contains=shDerefError
  85.  
  86. " clusters: contains=@... clusters
  87. "==================================
  88. syn cluster shCaseEsacList    contains=shCaseStart,shCase,shCaseBar,shCaseIn,shComment,shDeref,shCommandSub
  89. syn cluster shDblQuoteList    contains=shCommandSub,shDeref,shSpecial,shPosnParm
  90. syn cluster shDerefList    contains=shDerefOp,shDerefError,shDerefOpError,shExpr
  91. syn cluster shIdList    contains=shCommandSub,shWrapLineOperator,shIdWhiteSpace,shDeref,shSpecial
  92.  
  93. " clusters: contains=ALLBUT,@... clusters
  94. "=========================================
  95. syn cluster shCaseList    contains=shCase,shCaseStart,shCaseBar,shDblBrace,shDerefOp,shDerefText,@shErrorCaseList,shDerefVar,shDerefOpError,shStringSpecial,shSkipInitWS,shIdWhiteSpace,shDerefTextError,shPattern,shSetIdentifier
  96. syn cluster shColonList    contains=shCase,shCaseStart,shCaseBar,shDblBrace,shDerefOp,shDerefText,shFunction,shTestOpr,@shErrorColonList,shDerefVar,shDerefOpError,shStringSpecial,shSkipInitWS,shIdWhiteSpace,shDerefTextError,shPattern,shSetIdentifier
  97. syn cluster shCommandSubList1    contains=shCase,shCaseStart,shCaseBar,shDblBrace,shCommandSub,shDerefOp,shDerefText,shEcho,shFunction,shTestOpr,@shErrorList,shDerefVar,shDerefOpError,shStringSpecial,shIdWhiteSpace,shDerefTextError,shPattern,shSetIdentifier
  98. syn cluster shCommandSubList2    contains=shCase,shCaseStart,shCaseBar,shDblBrace,shDerefOp,shDerefText,shEcho,shFunction,shTestOpr,@shErrorList,shDerefVar,shDerefOpError,shStringSpecial,shIdWhiteSpace,shDerefTextError,shPattern,shSetIdentifier
  99. syn cluster shLoopList    contains=@shErrorLoopList,shCase,shCaseStart,shInEsac,shCaseBar,shDerefOp,shDerefText,shDerefVar,shDerefOpError,shStringSpecial,shSkipInitWS,shIdWhiteSpace,shDerefTextError,shPattern,shSetIdentifier
  100. syn cluster shExprList1    contains=shCase,shCaseStart,shCaseBar,shDblBrace,shDerefOp,shDerefText,shFunction,shSetList,@shErrorNoneList,shDerefVar,shDerefOpError,shStringSpecial,shSkipInitWS,shIdWhiteSpace,shDerefTextError,shPattern,shSetIdentifier
  101. syn cluster shExprList2    contains=shCase,shCaseStart,shCaseBar,shDblBrace,shDerefOp,shDerefText,@shErrorNoneList,shDerefVar,shDerefOpError,shStringSpecial,shSkipInitWS,shIdWhiteSpace,shDerefTextError,shPattern,shSetIdentifier
  102. syn cluster shSubShList    contains=shCase,shCaseStart,shCaseBar,shDblBrace,shDerefOp,shDerefText,shParenError,shDerefVar,shDerefOpError,shStringSpecial,shSkipInitWS,shDerefError,shIdWhiteSpace,shDerefTextError,shPattern,shSetIdentifier
  103. syn cluster shTestList    contains=shCase,shCaseStart,shCaseBar,shDblBrace,shDTestError,shDerefError,shDerefOp,shDerefText,shExpr,shFunction,shSetList,shTestError,shDerefVar,shDerefOpError,shStringSpecial,shSkipInitWS,shIdWhiteSpace,shDerefTextError,shPattern,shSetIdentifier
  104. syn cluster shFunctionList    contains=shCase,shCaseStart,shCaseBar,shDblBrace,@shErrorFuncList,shDerefOp,shDerefText,shFunction,shDerefVar,shDerefOpError,shStringSpecial,shSkipInitWS,shIdWhiteSpace,shDerefTextError,shPattern,shSetIdentifier
  105.  
  106. " Tests
  107. "======
  108. syn region  shExpr transparent matchgroup=shOperator start="\[" skip=+\\\\\|\\$+ end="\]" contains=ALLBUT,@shTestList
  109. syn region  shExpr transparent matchgroup=shStatement start="\<test\>" skip=+\\\\\|\\$+ matchgroup=NONE end="[;&|]"me=e-1 end="$" contains=ALLBUT,@shExprList1
  110. if exists("b:is_kornshell")
  111.  syn region  shDblBrace transparent matchgroup=shOperator start="\[\[" skip=+\\\\\|\\$+ end="\]\]" contains=ALLBUT,@shTestList
  112. endif
  113. syn match   shTestOpr contained "[!=]\|-.\>\|-\(nt\|ot\|ef\|eq\|ne\|lt\|le\|gt\|ge\)\>"
  114.  
  115. " do, if, while, until
  116. syn region shDo  transparent matchgroup=shConditional start="\<do\>" matchgroup=shConditional end="\<done\>" contains=ALLBUT,@shLoopList
  117. syn region shIf  transparent matchgroup=shConditional start="\<if\>" matchgroup=shConditional end="\<fi\>"   contains=ALLBUT,@shLoopList
  118. syn region shFor matchgroup=shStatement start="\<for\>" end="\<in\>" end="\<do\>"me=e-2    contains=ALLBUT,@shLoopList
  119. if exists("b:is_kornshell") || exists("b:is_bash")
  120.   syn region shRepeat   matchgroup=shStatement   start="\<while\>" end="\<in\>" end="\<do\>"me=e-2    contains=ALLBUT,@shLoopList
  121.   syn region shRepeat   matchgroup=shStatement   start="\<until\>" end="\<in\>" end="\<do\>"me=e-2    contains=ALLBUT,@shLoopList
  122.   syn region shCaseEsac matchgroup=shConditional start="\<select\>" matchgroup=shConditional end="\<in\>" end="\<do\>" contains=ALLBUT,@shLoopList
  123. endif
  124.  
  125. " case
  126. syn region  shCaseEsac    matchgroup=shConditional start="\<case\>" matchgroup=shConditional end="\<esac\>" contains=@shCaseEsacList
  127. syn keyword shCaseIn    contained skipwhite skipnl in            nextgroup=shCase,shCaseStart,shCaseBar,shComment
  128. syn region  shCase    contained skipwhite skipnl matchgroup=shConditional start="[^$()]\{-})"ms=s,hs=e  end=";;" end="esac"me=s-1 contains=ALLBUT,@shCaseList nextgroup=shCase,shCaseStart,shCaseBar,shComment
  129. syn match   shCaseStart    contained skipwhite skipnl "("        nextgroup=shCase
  130. syn match   shCaseBar    contained "[^|)]\{-}|"hs=e            nextgroup=shCase,shCaseStart,shCaseBar
  131.  
  132. syn region shExpr  transparent matchgroup=shExprRegion start="{" end="}"        contains=ALLBUT,@shExprList2
  133. syn region shSubSh transparent matchgroup=shSubShRegion start="(" end=")"        contains=ALLBUT,@shSubShList
  134.  
  135. " Misc
  136. "=====
  137. syn match   shOperator    "[!&;|]"
  138. syn match   shOperator    "\[\[[^:]\|]]"
  139. syn match   shCharClass    "\[:\(backspace\|escape\|return\|xdigit\|alnum\|alpha\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|tab\):\]"
  140. syn match   shOperator    "!\=="    skipwhite nextgroup=shPattern
  141. syn match   shPattern    "\<\S\+"    contained contains=shSinglequote,shDoublequote,shDeref
  142. syn match   shWrapLineOperator "\\$"
  143. syn region  shCommandSub   start="`" skip="\\`" end="`" contains=ALLBUT,@shCommandSubList1
  144.  
  145. " $(..) is not supported by sh (Bourne shell).  However, apparently
  146. " some systems (HP?) have as their /bin/sh a (link to) Korn shell
  147. " (ie. Posix compliant shell).  /bin/ksh should work for those
  148. " systems too, however, so the following syntax will flag $(..) as
  149. " an Error under /bin/sh.  By consensus of vimdev'ers!
  150. if exists("b:is_kornshell") || exists("b:is_bash")
  151.  syn region shCommandSub matchgroup=shCmdSubRegion start="\$(" end=")"  contains=ALLBUT,@shCommandSubList2
  152.  syn region shArithmetic matchgroup=shArithRegion start="\$((" end="))" contains=ALLBUT,@shCommandSubList2
  153.  syn match  shSkipInitWS contained    "^\s\+"
  154. else
  155.  syn region shCommandSub matchgroup=Error start="$(" end=")" contains=ALLBUT,@shCommandSubList2
  156. endif
  157.  
  158. if exists("b:is_bash")
  159.  syn keyword bashSpecialVariables contained    BASH    HISTCONTROL    LANG    OPTERR    PWD
  160.  syn keyword bashSpecialVariables contained    BASH_ENV    HISTFILE    LC_ALL    OPTIND    RANDOM
  161.  syn keyword bashSpecialVariables contained    BASH_VERSINFO    HISTFILESIZE    LC_COLLATE    OSTYPE    REPLY
  162.  syn keyword bashSpecialVariables contained    BASH_VERSION    HISTIGNORE    LC_MESSAGES    PATH    SECONDS
  163.  syn keyword bashSpecialVariables contained    CDPATH    HISTSIZE    LINENO    PIPESTATUS    SHELLOPTS
  164.  syn keyword bashSpecialVariables contained    DIRSTACK    HOME    MACHTYPE    PPID    SHLVL
  165.  syn keyword bashSpecialVariables contained    EUID    HOSTFILE    MAIL    PROMPT_COMMAND    TIMEFORMAT
  166.  syn keyword bashSpecialVariables contained    FCEDIT    HOSTNAME    MAILCHECK    PS1    TIMEOUT
  167.  syn keyword bashSpecialVariables contained    FIGNORE    HOSTTYPE    MAILPATH    PS2    UID
  168.  syn keyword bashSpecialVariables contained    GLOBIGNORE    IFS    OLDPWD    PS3    auto_resume
  169.  syn keyword bashSpecialVariables contained    GROUPS    IGNOREEOF    OPTARG    PS4    histchars
  170.  syn keyword bashSpecialVariables contained    HISTCMD    INPUTRC
  171.  syn keyword bashStatement        chmod    fgrep    install    rm    sort
  172.  syn keyword bashStatement        clear    find    less    rmdir    strip
  173.  syn keyword bashStatement        du    gnufind    ls    rpm    tail
  174.  syn keyword bashStatement        egrep    gnugrep    mkdir    sed    touch
  175.  syn keyword bashStatement        expr    grep    mv    sleep    complete
  176.  syn keyword bashAdminStatement    daemon    killproc    reload    start    stop
  177.  syn keyword bashAdminStatement    killall    nice    restart    status
  178. endif
  179.  
  180. if exists("b:is_kornshell")
  181.  syn keyword kshSpecialVariables contained    CDPATH    HISTFILE    MAILCHECK    PPID    RANDOM
  182.  syn keyword kshSpecialVariables contained    COLUMNS    HISTSIZE    MAILPATH    PS1    REPLY
  183.  syn keyword kshSpecialVariables contained    EDITOR    HOME    OLDPWD    PS2    SECONDS
  184.  syn keyword kshSpecialVariables contained    ENV    IFS    OPTARG    PS3    SHELL
  185.  syn keyword kshSpecialVariables contained    ERRNO    LINENO    OPTIND    PS4    TMOUT
  186.  syn keyword kshSpecialVariables contained    FCEDIT    LINES    PATH    PWD    VISUAL
  187.  syn keyword kshSpecialVariables contained    FPATH    MAIL
  188.  syn keyword kshStatement        cat    expr    less    printenv    strip
  189.  syn keyword kshStatement        chmod    fgrep    ls    rm    stty
  190.  syn keyword kshStatement        clear    find    mkdir    rmdir    tail
  191.  syn keyword kshStatement        cp    grep    mv    sed    touch
  192.  syn keyword kshStatement        du    install    nice    sort    tput
  193.  syn keyword kshStatement        egrep    killall
  194. endif
  195.  
  196. syn match   shSource    "^\.\s"
  197. syn match   shSource    "\s\.\s"
  198. syn region  shColon    start="^\s*:" end="$\|" end="#"me=e-1 contains=ALLBUT,@shColonList
  199.  
  200. " Comments
  201. "=========
  202. syn keyword    shTodo    contained    TODO
  203. syn cluster    shCommentGroup    contains=shTodo
  204. syn match    shComment        "#.*$" contains=@shCommentGroup
  205.  
  206. " String and Character constants
  207. "===============================
  208. syn match   shNumber        "-\=\<\d\+\>"
  209. syn match   shSpecial    contained    "\\\d\d\d\|\\[abcfnrtv0]"
  210. syn region  shSinglequote    matchgroup=shOperator start=+'+ end=+'+        contains=shStringSpecial
  211. syn region  shDoubleQuote     matchgroup=shOperator start=+"+ skip=+\\"+ end=+"+    contains=@shDblQuoteList,shStringSpecial
  212. syn match   shStringSpecial    contained    "[^[:print:]]"
  213. syn match   shSpecial        "\\[\\\"\'`$]"
  214.  
  215. " File redirection highlighted as operators
  216. "==========================================
  217. syn match    shRedir    "\d\=>\(&[-0-9]\)\="
  218. syn match    shRedir    "\d\=>>-\="
  219. syn match    shRedir    "\d\=<\(&[-0-9]\)\="
  220. syn match    shRedir    "\d<<-\="
  221.  
  222. " Shell Input Redirection (Here Documents)
  223. if version < 600
  224.  syn region shHereDoc matchgroup=shRedir start="<<\s*\**END[a-zA-Z_0-9]*\**"  matchgroup=shRedir end="^END[a-zA-Z_0-9]*$"
  225.  syn region shHereDoc matchgroup=shRedir start="<<-\s*\**END[a-zA-Z_0-9]*\**" matchgroup=shRedir end="^\s*END[a-zA-Z_0-9]*$"
  226.  syn region shHereDoc matchgroup=shRedir start="<<\s*\**EOF\**"  matchgroup=shRedir end="^EOF$"
  227.  syn region shHereDoc matchgroup=shRedir start="<<-\s*\**EOF\**" matchgroup=shRedir end="^\s*EOF$"
  228.  syn region shHereDoc matchgroup=shRedir start="<<\s*\**\.\**"  matchgroup=shRedir end="^\.$"
  229.  syn region shHereDoc matchgroup=shRedir start="<<-\s*\**\.\**" matchgroup=shRedir end="^\s*\.$"
  230. else
  231.  syn region shHereDoc matchgroup=shRedir start="<<\s*\**\z(\h\w*\)\**"  matchgroup=shRedir end="^\z1$"
  232.  syn region shHereDoc matchgroup=shRedir start="<<-\s*\**\z(\h\w*\)\**" matchgroup=shRedir end="^\s*\z1$"
  233. endif
  234.  
  235. " Identifiers
  236. "============
  237. syn match  shVariable "\<\h\w*="me=e-1    nextgroup=shSetIdentifier
  238. syn match  shIdWhiteSpace  contained    "\s"
  239. syn match  shSetIdentifier contained    "=" nextgroup=shString,shPattern
  240. if exists("b:is_bash")
  241.   syn region shSetList matchgroup=shStatement start="\<\(declare\|typeset\|local\|export\|set\|unset\)\>[^/]"me=e-1 end="$" end="[|)]"me=e-1 matchgroup=shOperator end="[;&]"me=e-1 matchgroup=NONE end="#\|="me=e-1 contains=@shIdList
  242.   syn match  shStatement "\<\(declare\|typeset\|local\|export\|set\|unset\)$"
  243. elseif exists("b:is_kornshell")
  244.   syn region shSetList matchgroup=shStatement start="\<\(typeset\|set\|export\|unset\)\>[^/]"me=e-1 end="$" end="[)|]"me=e-1 matchgroup=shOperator end="[;&]"me=e-1 matchgroup=NONE end="[#=]"me=e-1 contains=@shIdList
  245.   syn match  shStatement "\<\(typeset\|set\|export\|unset\)$"
  246. else
  247.   syn region shSetList matchgroup=shStatement start="\<\(set\|export\|unset\)\>[^/]"me=e-1 end="$" end="[)|]"me=e-1 matchgroup=shOperator end="[;&]" matchgroup=NONE end="[#=]"me=e-1 contains=@shIdList
  248.   syn match  shStatement "\<\(set\|export\|unset\)$"
  249. endif
  250.  
  251. if exists("b:is_bash") || exists("b:is_kornshell")
  252.   " handles functions which start:  Function () {
  253.   syn match  shFunction    "^\s*\<\h\w*\>\s*()"    skipwhite skipnl nextgroup=shFunctionRegion
  254.   syn region shFunctionRegion    transparent    matchgroup=Delimiter    start="{" end="}" contains=ALLBUT,@shFunctionList
  255. endif
  256. syn region shDeref    oneline    start="\${" end="}"    contains=shDeref,shDerefVar
  257. syn match  shDeref        "\$\h\w*\>"
  258. syn match  shDerefVar    contained    "\d\+\>"        nextgroup=@shDerefList
  259. syn match  shDerefVar    contained    "\h\w*\>"        nextgroup=@shDerefList
  260. if exists("b:is_bash")
  261.   syn match  shDerefVar    contained    "[-@*?!]"        nextgroup=@shDerefList
  262.   syn match  shDerefOp    contained    ":[^-=?+]"me=e-1    nextgroup=shDeref,shDerefVar,shPosnParm
  263. else
  264.   syn match  shDerefVar    contained    "[-#@*?!]"        nextgroup=@shDerefList
  265. endif
  266. syn match  shDerefVar    contained    "\$[^{(]"me=s+1    nextgroup=@shDerefList
  267. syn match  shPosnParm        "\$[-#@*$?!0-9]"    nextgroup=shDerefOp
  268. syn match  shDerefOpError    contained    "[^:}[]"
  269. syn match  shDerefOp    contained    ":\=[-=?+]"        nextgroup=shDerefText
  270. syn region shDerefText    contained    start="[^{}]"    end="}"me=e-1    contains=shDeref,shCommandSub,shDoubleQuote,shSingleQuote,shDerefTextError
  271. syn match  shDerefTextError    contained    "^."
  272. syn match  shDerefError    contained    "\s.\{-}}"me=e-1
  273. syn region shDerefText    contained    start="{"    end="}"    contains=shDeref,shCommandSub
  274.  
  275. if exists("b:is_kornshell") || exists("b:is_bash")
  276.  syn match shDerefVar    contained    "#\(\d\+\|\h\w*\)"    nextgroup=shDerefOp,shDerefError,shDerefOpError,shExpr
  277.  syn match shDerefOp    contained    "##\|%%\|[#%]"        nextgroup=shDerefText
  278. endif
  279.  
  280. " A bunch of useful sh keywords
  281. syn keyword shStatement    break    eval    newgrp    return    ulimit
  282. syn keyword shStatement    cd    exec    pwd    shift    umask
  283. syn keyword shStatement    chdir    exit    read    test    wait
  284. syn keyword shStatement    continue    kill    readonly    trap
  285. syn keyword shConditional    elif    else    then
  286.  
  287. if exists("b:is_kornshell") || exists("b:is_bash")
  288.  syn keyword shFunction    function
  289.  syn keyword shStatement    alias    fg    integer    printf    times
  290.  syn keyword shStatement    autoload    functions    jobs    r    true
  291.  syn keyword shStatement    bg    getopts    let    stop    type
  292.  syn keyword shStatement    false    hash    nohup    suspend    unalias
  293.  syn keyword shStatement    fc    history    print    time    whence
  294.  
  295.  if exists("b:is_bash")
  296.   syn keyword shStatement    bind    disown    help    popd    shopt
  297.   syn keyword shStatement    builtin    enable    logout    pushd    source
  298.   syn keyword shStatement    dirs
  299.  else
  300.   syn keyword shStatement    login    newgrp
  301.  endif
  302. endif
  303.  
  304. " Syncs
  305. " =====
  306. if !exists("sh_minlines")
  307.   let sh_minlines = 200
  308. endif
  309. if !exists("sh_maxlines")
  310.   let sh_maxlines = 2 * sh_minlines
  311. endif
  312. exec "syn sync minlines=" . sh_minlines . " maxlines=" . sh_maxlines
  313. syn sync match shCaseEsacSync grouphere    shCaseEsac    "\<case\>"
  314. syn sync match shCaseEsacSync groupthere    shCaseEsac    "\<esac\>"
  315. syn sync match shDoSync    grouphere    shDo    "\<do\>"
  316. syn sync match shDoSync    groupthere    shDo    "\<done\>"
  317. syn sync match shForSync    grouphere    shFor    "\<for\>"
  318. syn sync match shForSync    groupthere    shFor    "\<in\>"
  319. syn sync match shIfSync    grouphere    shIf    "\<if\>"
  320. syn sync match shIfSync    groupthere    shIf    "\<fi\>"
  321. if exists("b:is_kornshell") || exists("b:is_bash")
  322.  syn sync match shUntilSync    grouphere    shRepeat    "\<until\>"
  323.  syn sync match shWhileSync    grouphere    shRepeat    "\<while\>"
  324. endif
  325.  
  326. " The default highlighting.
  327. hi def link shArithRegion        shShellVariables
  328. hi def link shCaseBar        shConditional
  329. hi def link shCaseIn        shConditional
  330. hi def link shCaseStart        shConditional
  331. hi def link shCmdSubRegion        shShellVariables
  332. hi def link shColon        shStatement
  333. hi def link shDeref        shShellVariables
  334. hi def link shDerefOp        shOperator
  335. hi def link shDerefVar        shShellVariables
  336. hi def link shDoubleQuote        shString
  337. hi def link shEcho        shString
  338. hi def link shEmbeddedEcho        shString
  339. hi def link shHereDoc        shString
  340. hi def link shOption        shCommandSub
  341. hi def link shPattern        shString
  342. hi def link shPosnParm        shShellVariables
  343. hi def link shRedir        shOperator
  344. hi def link shSinglequote        shString
  345. hi def link shSource        shOperator
  346. hi def link shStringSpecial        shSpecial
  347. hi def link shSubShRegion        shOperator
  348. hi def link shTestOpr        shConditional
  349. hi def link shVariable        shSetList
  350. hi def link shWrapLineOperator    shOperator
  351.  
  352. if exists("b:is_bash")
  353.   hi def link bashAdminStatement    shStatement
  354.   hi def link bashSpecialVariables    shShellVariables
  355.   hi def link bashStatement        shStatement
  356. endif
  357. if exists("b:is_kornshell")
  358.   hi def link kshSpecialVariables    shShellVariables
  359.   hi def link kshStatement        shStatement
  360. endif
  361.  
  362. hi def link shCaseError        Error
  363. hi def link shCurlyError        Error
  364. hi def link shDerefError        Error
  365. hi def link shDerefOpError        Error
  366. hi def link shDerefTextError        Error
  367. hi def link shDoError        Error
  368. hi def link shEsacError        Error
  369. hi def link shIfError        Error
  370. hi def link shInError        Error
  371. hi def link shParenError        Error
  372. hi def link shTestError        Error
  373. if exists("b:is_kornshell")
  374.   hi def link shDTestError        Error
  375. endif
  376.  
  377. hi def link shArithmetic        Special
  378. hi def link shCharClass        Identifier
  379. hi def link shCommandSub        Special
  380. hi def link shComment        Comment
  381. hi def link shConditional        Conditional
  382. hi def link shExprRegion        Delimiter
  383. hi def link shFunction        Function
  384. hi def link shFunctionName        Function
  385. hi def link shNumber        Number
  386. hi def link shOperator        Operator
  387. if exists("b:is_kornshell") || exists("b:is_bash")
  388.  hi def link shRepeat        Repeat
  389. endif
  390. hi def link shSetList        Identifier
  391. hi def link shShellVariables        PreProc
  392. hi def link shSpecial        Special
  393. hi def link shStatement        Statement
  394. hi def link shString        String
  395. hi def link shTodo        Todo
  396.  
  397. " Current Syntax
  398. " ==============
  399. if exists("b:is_bash")
  400.  let b:current_syntax = "bash"
  401. elseif exists("b:is_kornshell")
  402.  let b:current_syntax = "ksh"
  403. else
  404.  let b:current_syntax = "sh"
  405. endif
  406.  
  407. " vim: ts=15
  408.