From 9afa0d25a66f849452f498bd45e2f443f5010635 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Tue, 27 Jul 2021 10:46:24 -0600 Subject: 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). --- runtime/syntax/syncolor.vim | 89 --------------------------------------------- runtime/syntax/synload.vim | 5 --- 2 files changed, 94 deletions(-) delete mode 100644 runtime/syntax/syncolor.vim (limited to 'runtime/syntax') diff --git a/runtime/syntax/syncolor.vim b/runtime/syntax/syncolor.vim deleted file mode 100644 index 27cc3360c4..0000000000 --- a/runtime/syntax/syncolor.vim +++ /dev/null @@ -1,89 +0,0 @@ -" Vim syntax support file -" Maintainer: Bram Moolenaar -" Last Change: 2020 Feb 13 - -" This file sets up the default methods for highlighting. -" It is loaded from "synload.vim" and from Vim for ":syntax reset". -" Also used from init_highlight(). - -if !exists("syntax_cmd") || syntax_cmd == "on" - " ":syntax on" works like in Vim 5.7: set colors but keep links - command -nargs=* SynColor hi - command -nargs=* SynLink hi link -else - if syntax_cmd == "enable" - " ":syntax enable" keeps any existing colors - command -nargs=* SynColor hi def - command -nargs=* SynLink hi def link - elseif syntax_cmd == "reset" - " ":syntax reset" resets all colors to the default - command -nargs=* SynColor hi - command -nargs=* SynLink hi! link - else - " User defined syncolor file has already set the colors. - finish - endif -endif - -let did_syncolor = 1 - -" Many terminals can only use six different colors (plus black and white). -" Therefore the number of colors used is kept low. It doesn't look nice with -" too many colors anyway. -" Careful with "cterm=bold", it changes the color to bright for some terminals. -" There are two sets of defaults: for a dark and a light background. -if &background == "dark" - SynColor Comment term=bold cterm=NONE ctermfg=Cyan ctermbg=NONE gui=NONE guifg=#80a0ff guibg=NONE - SynColor Constant term=underline cterm=NONE ctermfg=Magenta ctermbg=NONE gui=NONE guifg=#ffa0a0 guibg=NONE - SynColor Special term=bold cterm=NONE ctermfg=LightRed ctermbg=NONE gui=NONE guifg=Orange guibg=NONE - SynColor Identifier term=underline cterm=bold ctermfg=Cyan ctermbg=NONE gui=NONE guifg=#40ffff guibg=NONE - SynColor Statement term=bold cterm=NONE ctermfg=Yellow ctermbg=NONE gui=bold guifg=#ffff60 guibg=NONE - SynColor PreProc term=underline cterm=NONE ctermfg=LightBlue ctermbg=NONE gui=NONE guifg=#ff80ff guibg=NONE - SynColor Type term=underline cterm=NONE ctermfg=LightGreen ctermbg=NONE gui=bold guifg=#60ff60 guibg=NONE - SynColor Underlined term=underline cterm=underline ctermfg=LightBlue gui=underline guifg=#80a0ff - SynColor Ignore term=NONE cterm=NONE ctermfg=black ctermbg=NONE gui=NONE guifg=bg guibg=NONE -else - SynColor Comment term=bold cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=NONE guifg=Blue guibg=NONE - SynColor Constant term=underline cterm=NONE ctermfg=DarkRed ctermbg=NONE gui=NONE guifg=Magenta guibg=NONE - " #6a5acd is SlateBlue - SynColor Special term=bold cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=#6a5acd guibg=NONE - SynColor Identifier term=underline cterm=NONE ctermfg=DarkCyan ctermbg=NONE gui=NONE guifg=DarkCyan guibg=NONE - SynColor Statement term=bold cterm=NONE ctermfg=Brown ctermbg=NONE gui=bold guifg=Brown guibg=NONE - " #6a0dad is Purple - SynColor PreProc term=underline cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=#6a0dad guibg=NONE - SynColor Type term=underline cterm=NONE ctermfg=DarkGreen ctermbg=NONE gui=bold guifg=SeaGreen guibg=NONE - SynColor Underlined term=underline cterm=underline ctermfg=DarkMagenta gui=underline guifg=SlateBlue - SynColor Ignore term=NONE cterm=NONE ctermfg=white ctermbg=NONE gui=NONE guifg=bg guibg=NONE -endif -SynColor Error term=reverse cterm=NONE ctermfg=White ctermbg=Red gui=NONE guifg=White guibg=Red -SynColor Todo term=standout cterm=NONE ctermfg=Black ctermbg=Yellow gui=NONE guifg=Blue guibg=Yellow - -" Common groups that link to default highlighting. -" You can specify other highlighting easily. -SynLink String Constant -SynLink Character Constant -SynLink Number Constant -SynLink Boolean Constant -SynLink Float Number -SynLink Function Identifier -SynLink Conditional Statement -SynLink Repeat Statement -SynLink Label Statement -SynLink Operator Statement -SynLink Keyword Statement -SynLink Exception Statement -SynLink Include PreProc -SynLink Define PreProc -SynLink Macro PreProc -SynLink PreCondit PreProc -SynLink StorageClass Type -SynLink Structure Type -SynLink Typedef Type -SynLink Tag Special -SynLink SpecialChar Special -SynLink Delimiter Special -SynLink SpecialComment Special -SynLink Debug Special - -delcommand SynColor -delcommand SynLink diff --git a/runtime/syntax/synload.vim b/runtime/syntax/synload.vim index aee9ba8b8e..bfcd3b06da 100644 --- a/runtime/syntax/synload.vim +++ b/runtime/syntax/synload.vim @@ -14,11 +14,6 @@ endif " let others know that syntax has been switched on let syntax_on = 1 -" Set the default highlighting colors -if !exists("colors_name") && !exists("did_syncolor") - runtime! syntax/syncolor.vim -endif - " Line continuation is used here, remove 'C' from 'cpoptions' let s:cpo_save = &cpo set cpo&vim -- cgit