diff options
author | Gregory Anders <greg@gpanders.com> | 2021-07-24 10:28:16 -0600 |
---|---|---|
committer | Gregory Anders <greg@gpanders.com> | 2021-07-24 10:28:16 -0600 |
commit | 860aedd06b6ea09c6337355226b9a93217fec531 (patch) | |
tree | 2e94681d1b0cfe748ac4741327661608a327ccf9 | |
parent | 46009499afbb0232124072d775caa9552d0f71de (diff) | |
download | rneovim-860aedd06b6ea09c6337355226b9a93217fec531.tar.gz rneovim-860aedd06b6ea09c6337355226b9a93217fec531.tar.bz2 rneovim-860aedd06b6ea09c6337355226b9a93217fec531.zip |
fix: source syncolors.vim after startup scripts
This fixes an issue introduced in #14771 (fix: source syncolors.vim
before startup scripts) that affected highlights for users who set
'background' to light in their startup script. Because syncolor.vim
checks for the value of &background, it was always setting up the 'dark'
background colors, which looked wrong for users using light backgrounds.
The primary benefit of #14771 is that it decoupled highlighting from the
syntax engine. This is useful for e.g. treesitter, which still makes use
of highlights even if the syntax engine is disabled. For this reason, it
is still worthwhile to source syncolor.vim separately from synload.vim,
which #14771 accomplishes. However, we should still source syncolor.vim
after the user startup scripts, to ensure that we are respecting the
options the user sets.
Another corollary benefit is that this reduces some redundancy in
highlight definitions, since we now only source syncolors.vim if the
user did not already enable a colorscheme.
-rw-r--r-- | src/nvim/main.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index cf9cb9cfbd..95cb53df43 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -366,19 +366,16 @@ int main(int argc, char **argv) // Execute --cmd arguments. exe_pre_commands(¶ms); - // If using the runtime (-u is not NONE), enable syntax & filetype plugins. - bool enable_syntax = - (params.use_vimrc == NULL || !strequal(params.use_vimrc, "NONE")); - - // Source syncolor.vim to set up default UI highlights - if (enable_syntax) { - source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL); - } - // Source startup scripts. source_startup_scripts(¶ms); - if (enable_syntax) { + // If using the runtime (-u is not NONE), enable syntax & filetype plugins. + if (params.use_vimrc == NULL || !strequal(params.use_vimrc, "NONE")) { + // Source syncolor.vim to set up default UI highlights if the user didn't + // already enable a colorscheme + if (!get_var_value("g:colors_name")) { + source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL); + } // Does ":filetype plugin indent on". filetype_maybe_enable(); // Sources syntax/syntax.vim, which calls `:filetype on`. |