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.  The idea is that all the default highlight groups are
reset to their default.  If a previous color scheme change, for example
"Special" then it gets set back to the default.  Then the color scheme
only needs to set the groups that are different from the default.
See $VIMRUNTIME/syntax/syncolor.vim for details.

-- 
hundred-and-one symptoms of being an internet addict:
195. Your cat has its own home page.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

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