Unnecessary "syntax reset"

40 views
Skip to first unread message

Maxim Kim

unread,
Sep 23, 2020, 12:52:38 PM9/23/20
to vim...@googlegroups.com

Hi, could someone with knowledge clarify if syntax reset is actually needed when authoring colorschemes?


From the issue description: https://github.com/vim/colorschemes/issues/34

" Load the syntax highlighting defaults, if it's enabled.
if exists("syntax_on")
    syntax reset
endif

Is this still necessary? ":hi clear" already achieves this as far as
I can tell.

":hi clear" causes syncolor.vim to be sourced, which, if syntax is on,
follows this path (condition true):

if !exists("syntax_cmd") || syntax_cmd == "on"

This causes the standard syntax links to be defined with "hi link"
rather than the "hi! link" of "syn reset", but since all groups have
already had their colours cleared, this has the same effect.

E.g.

hi Function ctermfg=1
hi! link Function Error
hi clear

"hi clear" removes the colour and resets the link to Identifier
(tested with Vim 8.2.869).

It looks like delek is the only standard colorscheme that doesn't do an
explicit "syn reset". The others cause syncolor.vim to be sourced twice.


Reply all
Reply to author
Forward
0 new messages