From a8dd4b486c2c8afd4e2b61ee7a9946a452368963 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 15 Nov 2017 07:48:40 +1300 Subject: Coax sh.vim into accepting #/% param expansion These forms of parameter expansion are specified in POSIX sh. --- vim/after/syntax/sh.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'vim') diff --git a/vim/after/syntax/sh.vim b/vim/after/syntax/sh.vim index 8025c567..4d56d3a8 100644 --- a/vim/after/syntax/sh.vim +++ b/vim/after/syntax/sh.vim @@ -119,6 +119,21 @@ if exists('b:is_posix') syntax cluster shCaseList add=shRepeat syntax cluster shFunctionList add=shRepeat + " ${foo%bar}, ${foo%%bar}, ${foo#bar}, and ${foo##bar} are all valid forms + " of parameter expansion in POSIX, but sh.vim makes them conditional on + " Bash or Korn shell. We reinstate them (slightly adapted) here. + syn match shDerefOp contained + \ '##\|#\|%%\|%' + \ nextgroup=@shDerefPatternList + syn match shDerefPattern contained + \ '[^{}]\+' + \ contains=shDeref,shDerefSimple,shDerefPattern,shDerefString,shCommandSub,shDerefEscape + \ nextgroup=shDerefPattern + syn region shDerefPattern contained + \ start='{' end='}' + \ contains=shDeref,shDerefSimple,shDerefString,shCommandSub + \ nextgroup=shDerefPattern + endif " Some corrections for highlighting specific to the Bash mode -- cgit v1.2.3