On Sat, Apr 02, 2016 at 05:14:30PM +0200, Bram Moolenaar wrote:
> 
> 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?
> 
> The command is a bit of a misnomer, it actually only affects
> highlighting.

Clearly that's not all it does since “syn iskeyword” is changed by “syn
reset”.  If it's only *intended* to reset the highlighting, then it
should be fixed to not also reset “syn iskeyword”.

Independent from the above bug fix, I think it would also be beneficial
to have the effect of resetting highlighting to defaults automatically
happen when “:colorscheme foo” is called.  There's no reason that every
single colorscheme should have to add the “syn reset” command.

Cheers,
-- 
James
GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <[email protected]>

-- 
-- 
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.

Raspunde prin e-mail lui