Re: Syntax Highlighting Doesn't Work with Recursive `nextgroup` Across Newlines When Contained
Dan Doel wrote: On Thu, Oct 31, 2013 at 11:53 AM, Charles Campbell charles.e.campb...@nasa.gov wrote: MMAMBMB # a b b # b b M At the time the syntax hilighter sees the # in # b b, note that '#\=\s*\zsb' DOES NOT MATCH. However, the M syntax DOES MATCH, and so its highlighted as MyComment. Syntax highlighting is tricky. This does not explain why the bs in the second line are still not matched even when the comment rule is removed. Is it that the entire nextgroup is thrown away, because the # is not officially part of the B match, so it is counted as not matching? I note that removing the '#\=\s*\zs' portion from the B match: syn clear syntax match MyComment '#.*$' contains=A syntax match A 'a' nextgroup=B skipwhite skipnl syntax match B 'b' contained nextgroup=B skipwhite skipnl highlight default link A Type highlight default link B Error highlight default link MyComment Comment and using it on # a b b b b b also shows the bs on the second line without highlighting. What I think is happening is that MyComment matches to only one line which may contain A; once a newline is encountered, the MyComment match terminates, taking the A and B matches with it. I tried using the extend keyword, but that didn't affect the resulting highlighting. Regards, C Campbell -- -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Syntax Highlighting Doesn't Work with Recursive `nextgroup` Across Newlines When Contained
On Fri, Nov 1, 2013 at 10:05 AM, Charles Campbell charles.e.campb...@nasa.gov wrote: I note that removing the '#\=\s*\zs' portion from the B match: syn clear syntax match MyComment '#.*$' contains=A syntax match A 'a' nextgroup=B skipwhite skipnl syntax match B 'b' contained nextgroup=B skipwhite skipnl highlight default link A Type highlight default link B Error highlight default link MyComment Comment and using it on # a b b b b b also shows the bs on the second line without highlighting. What I think is happening is that MyComment matches to only one line which may contain A; once a newline is encountered, the MyComment match terminates, taking the A and B matches with it. I tried using the extend keyword, but that didn't affect the resulting highlighting. Yes, I know that, too. But it wasn't what I was asking about. This is: syntax clear syntax match A 'a' nextgroup=B skipwhite skipnl syntax match B '#\=\s*\zsb' contained nextgroup=B skipwhite skipnl hi link A Type hi link B Error There is no comment rule at all. Just an A (which can start anywhere) and a contained B. But in: # a b b b # b b Only the first line is highlighted. If you remove the second #, then both lines are highlighted. I suppose it follows a kind of logic. Normally in: syntax match foo /a/ syntax match bar /aa/ bar takes precedence. However, as you mentioned, if you do: syntax match foo /a/ syntax match bar /a\zsa/ foo takes precedence, even though bar is later, because bar's actual match start doesn't cover the first character. And, a nextgroup is required to match immediately after whatever skip settings are in place. But even though b's pattern matches, the start of the match is not at the first character after skipping, so it is just rejected. I just wouldn't have anticipated that it worked that way. -- Dan -- -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Syntax Highlighting Doesn't Work with Recursive `nextgroup` Across Newlines When Contained
Dan Doel wrote: On Sunday, October 27, 2013 4:56:18 PM UTC-4, Christian Brabandt wrote: A workaround is something like this (which looks cleaner for me) syntax match MyComment '#.*$' contains=A,B syntax match A 'a' nextgroup=B skipwhite skipnl syntax match B 'b' contained nextgroup=B skipwhite skipnl This does something different, though. For instance, the original should not highlight the bs in the second row of: # a b b # c b b while the replacement will. I don't think the original should actually work as specified, since it would make sense to me for the nextgroups to be contained in the comment region, which is one line. But, even without the comment match, it doesn't work correctly; the \zs stops the pattern from matching for some reason, as noted, which doesn't seem right. (to make sense of my examples, please used a fixed width font) (am avoiding html to do this myself as that prompts screams and bewailings from some of the group) Now, including the OP's syntax highlighting: M: syntax match MyComment '#.*$' contains=A A: syntax match A 'a' nextgroup=B skipwhite skipnl B: syntax match B '#\=\s*\zsb' contained nextgroup=B skipwhite skipnl MMAMBMB # a b b # b b M At the time the syntax hilighter sees the # in # b b, note that '#\=\s*\zsb' DOES NOT MATCH. However, the M syntax DOES MATCH, and so its highlighted as MyComment. Syntax highlighting is tricky. Regards, Charles Campbell -- -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Syntax Highlighting Doesn't Work with Recursive `nextgroup` Across Newlines When Contained
On Thu, Oct 31, 2013 at 11:53 AM, Charles Campbell charles.e.campb...@nasa.gov wrote: MMAMBMB # a b b # b b M At the time the syntax hilighter sees the # in # b b, note that '#\=\s*\zsb' DOES NOT MATCH. However, the M syntax DOES MATCH, and so its highlighted as MyComment. Syntax highlighting is tricky. This does not explain why the bs in the second line are still not matched even when the comment rule is removed. Is it that the entire nextgroup is thrown away, because the # is not officially part of the B match, so it is counted as not matching? -- Dan -- -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Syntax Highlighting Doesn't Work with Recursive `nextgroup` Across Newlines When Contained
On So, 27 Okt 2013, Alexander Shukaev wrote: I've stumbled across the issue with syntax highlighting. Rather than rewriting, I'll post a link to the question on Stack Overflow: Vim: Syntax Highlighting Doesn't Work with Recursive `nextgroup` Across Newlines When Containedhttp://stackoverflow.com/questions/19614494/vim-syntax-highlighting-doesnt-work-with-recursive-nextgroup-across-newlines as there is code formatting. If it is absolutely necessary, I can repost it here, just tell me. Please, take a look at this. Please include a short description of the error in the mail, so one doesn't need to look up an error by starting a web browser. If I see this correctly, you are wondering why this: #v+ syntax match MyComment '#.*$' contains=A syntax match A 'a' nextgroup=B skipwhite skipnl syntax match B '#\=\s*\zsb' contained nextgroup=B skipwhite skipnl highlight default link A Type highlight default link B Error highlight default link MyComment Comment #v- Doesn't match the second line in: # a b b b # b b If I understand it correctly, I see no reason, why your comments should highlight the 'b' as you do not have the group 'B' contained inside the MyComment syntax match. (e.g. you are missing a leading 'a' in the second line). Best, Christian -- Es gibt Menschen, die geizen mit ihrem Verstand wie andere mit ihrem Geld. -- Ludwig Börne -- -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Syntax Highlighting Doesn't Work with Recursive `nextgroup` Across Newlines When Contained
On 27-Oct-2013 21:11 +0100, Christian Brabandt wrote: On So, 27 Okt 2013, Alexander Shukaev wrote: I've stumbled across the issue with syntax highlighting. Rather than rewriting, I'll post a link to the question on Stack Overflow: Vim: Syntax Highlighting Doesn't Work with Recursive `nextgroup` Across Newlines When Containedhttp://stackoverflow.com/questions/19614494/vim-syntax-highlighting-doesnt-work-with-recursive-nextgroup-across-newlines as there is code formatting. If it is absolutely necessary, I can repost it here, just tell me. Please, take a look at this. Please include a short description of the error in the mail, so one doesn't need to look up an error by starting a web browser. If I see this correctly, you are wondering why this: #v+ syntax match MyComment '#.*$' contains=A syntax match A 'a' nextgroup=B skipwhite skipnl syntax match B '#\=\s*\zsb' contained nextgroup=B skipwhite skipnl highlight default link A Type highlight default link B Error highlight default link MyComment Comment #v- Doesn't match the second line in: # a b b b # b b If I understand it correctly, I see no reason, why your comments should highlight the 'b' as you do not have the group 'B' contained inside the MyComment syntax match. (e.g. you are missing a leading 'a' in the second line). In the first line, group 'A' prefers a following 'B' via the nextgroup=B, and this does work for the next 3 'b' in the same line. It apparently fails in the second line, even though skipnl has been given. -- regards, ingo -- -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Syntax Highlighting Doesn't Work with Recursive `nextgroup` Across Newlines When Contained
On So, 27 Okt 2013, Ingo Karkat wrote: In the first line, group 'A' prefers a following 'B' via the nextgroup=B, and this does work for the next 3 'b' in the same line. It apparently fails in the second line, even though skipnl has been given. Ah, now I see. The MyComments match confused me. It looks like the \zs makes the pattern not match. The same happens when using the \@= atom. A workaround is something like this (which looks cleaner for me) syntax match MyComment '#.*$' contains=A,B syntax match A 'a' nextgroup=B skipwhite skipnl syntax match B 'b' contained nextgroup=B skipwhite skipnl Best, Christian -- Was man nicht im Kopf hat, muß man im Computer haben. -- -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.