On Wednesday, March 30, 2016 at 9:58:29 PM UTC-5, James McCoy wrote:
> There seems to be a snippet that's been cargo-culted into colorschemes,
> but I can't find justification for.
>
> if exists('syntax_on')
> syntax reset
> endif
>
> Given that syntax items just link to highlight groups and it's the
> highlight groups which define the colors, why should a colorscheme be
> calling ":syntax reset"?
>
> The reason I noticed this is that there's actually a noticeable impact
> of resetting the syntax now. If there was before, I never encountered
> it.
>
> If a syntax file is using ":syn iskeyword", then this is cleared when a
> user changes their colorscheme, breaking the highlighting that was in
> effect. This can trivially be seen with the sh syntax.
>
> --8<--
> #!/bin/sh
> apply_patch make-some-case-work
>
> if true; then
> echo Something
> fi
> -->8--
>
> Given the above foo.sh, everything looks appropriately highlighted when
> initially opened. Set the colorscheme again (even just back to what it
> is -- :exe 'color '.g:colors_name) and now the fi is highlighted as an
> error while most of the rest has lost its highlighting.
>
> So, is this just a relic of the original implementation or is there
> an actual reason that this snippet needs to be put into colorschemes?
> If it's legitimate, shouldn't it be done by Vim instead of cargo-culted
> into every colorscheme?
>
I've seen colorschemes reach into specific syntaxes and highlight individual
groups, overriding the links. I'd guess the syn reset command is to recover
from that when switching to a new scheme. See for example, solarized.
--
--
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.