diff options
author | Gregory Anders <greg@gpanders.com> | 2021-07-27 10:46:24 -0600 |
---|---|---|
committer | Gregory Anders <greg@gpanders.com> | 2021-07-27 14:14:30 -0600 |
commit | 9afa0d25a66f849452f498bd45e2f443f5010635 (patch) | |
tree | 08dc4ca54b512fecc886c17c9aac77dd8a3abce6 /src/nvim/syntax.c | |
parent | c642f3ac27aa842e374334d11291fd5129ab6887 (diff) | |
download | rneovim-9afa0d25a66f849452f498bd45e2f443f5010635.tar.gz rneovim-9afa0d25a66f849452f498bd45e2f443f5010635.tar.bz2 rneovim-9afa0d25a66f849452f498bd45e2f443f5010635.zip |
fix(highlight): remove syncolor.vim
Remove syncolor.vim in favor of defining the default highlight groups
directly in `init_highlight`. This approach provides a number of
advantages:
1. The highlights are always defined, regardless of whether or not the
syntax regex engine is enabled.
2. Redundant sourcing of syntax files is eliminated (syncolor.vim was
often sourced multiple times based on how the user's colorscheme file
was written).
3. The syntax highlighting regex engine and the highlight groups
themselves are more fully decoupled.
4. Removal of the confusing `:syntax on` / `:syntax enable` dichotomy
(they now both do the same thing).
This approach also correctly solves a number of bugs related to
highlighting (#15176, #12573, #15205).
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r-- | src/nvim/syntax.c | 66 |
1 files changed, 46 insertions, 20 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 6347d83626..dcca25ccee 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -3421,9 +3421,7 @@ static void syn_cmd_on(exarg_T *eap, int syncing) */ static void syn_cmd_enable(exarg_T *eap, int syncing) { - set_internal_string_var("syntax_cmd", (char_u *)"enable"); - syn_cmd_onoff(eap, "syntax"); - do_unlet(S_LEN("g:syntax_cmd"), true); + syn_cmd_on(eap, syncing); } /* @@ -3434,9 +3432,7 @@ static void syn_cmd_reset(exarg_T *eap, int syncing) { eap->nextcmd = check_nextcmd(eap->arg); if (!eap->skip) { - set_internal_string_var("syntax_cmd", (char_u *)"reset"); - do_cmdline_cmd("runtime! syntax/syncolor.vim"); - do_unlet(S_LEN("g:syntax_cmd"), true); + init_highlight(true, true); } } @@ -6057,6 +6053,32 @@ static const char *highlight_init_both[] = { "RedrawDebugClear ctermbg=Yellow guibg=Yellow", "RedrawDebugComposed ctermbg=Green guibg=Green", "RedrawDebugRecompose ctermbg=Red guibg=Red", + "Error term=reverse cterm=NONE ctermfg=White ctermbg=Red gui=NONE guifg=White guibg=Red", + "Todo term=standout cterm=NONE ctermfg=Black ctermbg=Yellow gui=NONE guifg=Blue guibg=Yellow", + "default link String Constant", + "default link Character Constant", + "default link Number Constant", + "default link Boolean Constant", + "default link Float Number", + "default link Function Identifier", + "default link Conditional Statement", + "default link Repeat Statement", + "default link Label Statement", + "default link Operator Statement", + "default link Keyword Statement", + "default link Exception Statement", + "default link Include PreProc", + "default link Define PreProc", + "default link Macro PreProc", + "default link PreCondit PreProc", + "default link StorageClass Type", + "default link Structure Type", + "default link Typedef Type", + "default link Tag Special", + "default link SpecialChar Special", + "default link Delimiter Special", + "default link SpecialComment Special", + "default link Debug Special", NULL }; @@ -6090,6 +6112,15 @@ static const char *highlight_init_light[] = { "Title ctermfg=DarkMagenta gui=bold guifg=Magenta", "Visual guibg=LightGrey", "WarningMsg ctermfg=DarkRed guifg=Red", + "Comment term=bold cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=NONE guifg=Blue guibg=NONE", + "Constant term=underline cterm=NONE ctermfg=DarkRed ctermbg=NONE gui=NONE guifg=Magenta guibg=NONE", + "Special term=bold cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=#6a5acd guibg=NONE", + "Identifier term=underline cterm=NONE ctermfg=DarkCyan ctermbg=NONE gui=NONE guifg=DarkCyan guibg=NONE", + "Statement term=bold cterm=NONE ctermfg=Brown ctermbg=NONE gui=bold guifg=Brown guibg=NONE", + "PreProc term=underline cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=#6a0dad guibg=NONE", + "Type term=underline cterm=NONE ctermfg=DarkGreen ctermbg=NONE gui=bold guifg=SeaGreen guibg=NONE", + "Underlined term=underline cterm=underline ctermfg=DarkMagenta gui=underline guifg=SlateBlue", + "Ignore term=NONE cterm=NONE ctermfg=white ctermbg=NONE gui=NONE guifg=bg guibg=NONE", NULL }; @@ -6123,6 +6154,15 @@ static const char *highlight_init_dark[] = { "Title ctermfg=LightMagenta gui=bold guifg=Magenta", "Visual guibg=DarkGrey", "WarningMsg ctermfg=LightRed guifg=Red", + "Comment term=bold cterm=NONE ctermfg=Cyan ctermbg=NONE gui=NONE guifg=#80a0ff guibg=NONE", + "Constant term=underline cterm=NONE ctermfg=Magenta ctermbg=NONE gui=NONE guifg=#ffa0a0 guibg=NONE", + "Special term=bold cterm=NONE ctermfg=LightRed ctermbg=NONE gui=NONE guifg=Orange guibg=NONE", + "Identifier term=underline cterm=bold ctermfg=Cyan ctermbg=NONE gui=NONE guifg=#40ffff guibg=NONE", + "Statement term=bold cterm=NONE ctermfg=Yellow ctermbg=NONE gui=bold guifg=#ffff60 guibg=NONE", + "PreProc term=underline cterm=NONE ctermfg=LightBlue ctermbg=NONE gui=NONE guifg=#ff80ff guibg=NONE", + "Type term=underline cterm=NONE ctermfg=LightGreen ctermbg=NONE gui=bold guifg=#60ff60 guibg=NONE", + "Underlined term=underline cterm=underline ctermfg=LightBlue gui=underline guifg=#80a0ff", + "Ignore term=NONE cterm=NONE ctermfg=black ctermbg=NONE gui=NONE guifg=bg guibg=NONE", NULL }; @@ -6398,20 +6438,6 @@ void init_highlight(bool both, bool reset) } } - /* - * If syntax highlighting is enabled load the highlighting for it. - */ - if (get_var_value("g:syntax_on") != NULL) { - static int recursive = 0; - - if (recursive >= 5) { - EMSG(_("E679: recursive loop loading syncolor.vim")); - } else { - recursive++; - (void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL); - recursive--; - } - } syn_init_cmdline_highlight(false, false); } |