Hi,
I've noticed that syntax highlighting inside bash subshells is lacking
(comments are not rendered as such, for instance). Turns out that was because
the subshells were parsed as `shCmdParenRegion` which is for stuff like `cat
<<<(one-line command)`. Instead subshells should be parsed as `shSubSh`.
I've also allowed function definitions to be contained in a shSubSh.
Example to demonstrate:
myfunction() {
# This subshell is mistakenly parsed as shCmdParenRegion
(
# comments don't render
# and this function definition isn't parsed as such
foo() { true; }
)
# This was and should still be a shCmdParenRegion
cat <<<(echo yes)
}
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
# HG changeset patch
# User [email protected]
# Date 1400086382 -3600
# Wed May 14 17:53:02 2014 +0100
# Node ID 9d1ad8ded7e28ca8f50ebca60a88dc76c34ab62e
# Parent 32de51778c277a22f5aca6d1469cb1db9d3932c9
Fix detection of bash shSubSh(ells) instead of using shCmdParenRegion, and allow functions in SubSh
Before, shCommandSubList allowed shSubSh but also shCmdParenRegion, the latter
overriding the former. shCmdParenRegion is more restrictive and is probably
meant for one-line commands (such as: <<<(command) ) - for instance it doesn't
even support comments.
Making shCmdParenRegion contained and removing it from shCommandSubList allows
`shSubSh`s to be detected.
Example to demonstrate:
function myfunction {
# This subshell is mistakenly parsed as shCmdParenRegion
(
# comments don't render
# and this function definition isn't parsed as such
foo() { true; }
)
# This was and should still be a shCmdParenRegion
cat <<<(echo yes)
}
diff -r 32de51778c27 -r 9d1ad8ded7e2 runtime/syntax/sh.vim
--- a/runtime/syntax/sh.vim Tue May 13 20:23:24 2014 +0200
+++ b/runtime/syntax/sh.vim Wed May 14 17:53:02 2014 +0100
@@ -109,7 +109,7 @@
syn cluster shCaseEsacList contains=shCaseStart,shCase,shCaseBar,shCaseIn,shComment,shDeref,shDerefSimple,shCaseCommandSub,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote,shCtrlSeq,@shErrorList,shStringSpecial,shCaseRange
syn cluster shCaseList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq
"syn cluster shColonList contains=@shCaseList
-syn cluster shCommandSubList contains=shArithmetic,shDeref,shDerefSimple,shEcho,shEscape,shNumber,shOption,shPosnParm,shExSingleQuote,shSingleQuote,shExDoubleQuote,shDoubleQuote,shStatement,shVariable,shSubSh,shAlias,shTest,shCtrlSeq,shSpecial,shCmdParenRegion
+syn cluster shCommandSubList contains=shArithmetic,shDeref,shDerefSimple,shEcho,shEscape,shNumber,shOption,shPosnParm,shExSingleQuote,shSingleQuote,shExDoubleQuote,shDoubleQuote,shStatement,shVariable,shSubSh,shAlias,shTest,shCtrlSeq,shSpecial
syn cluster shCurlyList contains=shNumber,shComma,shDeref,shDerefSimple,shDerefSpecial
syn cluster shDblQuoteList contains=shCommandSub,shDeref,shDerefSimple,shEscape,shPosnParm,shCtrlSeq,shSpecial
syn cluster shDerefList contains=shDeref,shDerefSimple,shDerefVar,shDerefSpecial,shDerefWordError,shDerefPPS
@@ -128,7 +128,7 @@
syn cluster shIdList contains=shCommandSub,shWrapLineOperator,shSetOption,shDeref,shDerefSimple,shRedir,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shCtrlSeq,shStringSpecial,shAtExpr
syn cluster shIfList contains=@shLoopList,shDblBrace,shDblParen,shFunctionKey,shFunctionOne,shFunctionTwo
syn cluster shLoopList contains=@shCaseList,shTestOpr,shExpr,shDblBrace,shConditional,shCaseEsac,shTest,@shErrorList,shSet,shOption
-syn cluster shSubShList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shIf,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq,shOperator
+syn cluster shSubShList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shIf,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq,shOperator,shFunctionKey,shFunctionOne,shFunctionTwo
syn cluster shTestList contains=shCharClass,shComment,shCommandSub,shDeref,shDerefSimple,shExDoubleQuote,shDoubleQuote,shExpr,shNumber,shOperator,shExSingleQuote,shSingleQuote,shTestOpr,shTest,shCtrlSeq
" Echo: {{{1
" ====
@@ -280,7 +280,7 @@
elseif !exists("g:sh_no_error")
syn region shCommandSub matchgroup=Error start="\$(" end=")" contains=@shCommandSubList
endif
-syn region shCmdParenRegion matchgroup=shCmdSubRegion start="(" skip='\\\\\|\\.' end=")" contains=@shCommandSubList
+syn region shCmdParenRegion matchgroup=shCmdSubRegion start="(" skip='\\\\\|\\.' end=")" contains=@shCommandSubList contained
if exists("b:is_bash")
syn cluster shCommandSubList add=bashSpecialVariables,bashStatement