Merge pull request #15207 from gpanders/bye-syncolor

fix(highlight): remove syncolor.vim
This commit is contained in:
Björn Linse 2021-07-29 23:31:57 +02:00 committed by GitHub
commit d628e4250f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 104 additions and 232 deletions

View File

@ -25,11 +25,15 @@ In the User Manual:
==============================================================================
1. Quick start *:syn-qstart*
*:syn-enable* *:syntax-enable*
*:syn-enable* *:syntax-enable* *:syn-on* *:syntax-on*
This command switches on syntax highlighting: >
:syntax enable
Alternatively: >
:syntax on
What this command actually does is to execute the command >
:source $VIMRUNTIME/syntax/syntax.vim
@ -42,19 +46,11 @@ are in the "/usr/vim/vim82/syntax" directory, set $VIMRUNTIME to
This command also sources the |menu.vim| script when the GUI is running or
will start soon. See |'go-M'| about avoiding that.
*:syn-on* *:syntax-on*
The `:syntax enable` command will keep most of your current color settings.
This allows using `:highlight` commands to set your preferred colors before or
after using this command. If you want Vim to overrule your settings with the
defaults, use: >
:syntax on
<
*:hi-normal* *:highlight-normal*
If you are running in the GUI, you can get white text on a black background
with: >
:highlight Normal guibg=Black guifg=White
For a color terminal see |:hi-normal-cterm|.
For setting up your own colors syntax highlighting see |syncolor|.
NOTE: The syntax files on MS-Windows have lines that end in <CR><NL>.
The files for Unix end in <NL>. This means you should use the right type of
@ -277,12 +273,6 @@ located. This is used here as the variable |$VIMRUNTIME|.
|
+- Source first syntax/synload.vim in 'runtimepath'
| |
| +- Setup the colors for syntax highlighting. If a color scheme is
| | defined it is loaded again with ":colors {name}". Otherwise
| | ":runtime! syntax/syncolor.vim" is used. ":syntax on" overrules
| | existing colors, ":syntax enable" only sets groups that weren't
| | set yet.
| |
| +- Set up syntax autocmds to load the appropriate syntax file when
| | the 'syntax' option is set. *synload-1*
| |
@ -5271,51 +5261,10 @@ back to their Vim default.
Note that if you are using a color scheme, the colors defined by the color
scheme for syntax highlighting will be lost.
What this actually does is: >
let g:syntax_cmd = "reset"
runtime! syntax/syncolor.vim
Note that this uses the 'runtimepath' option.
*syncolor*
If you want to use different colors for syntax highlighting, you can add a Vim
script file to set these colors. Put this file in a directory in
'runtimepath' which comes after $VIMRUNTIME, so that your settings overrule
the default colors. This way these colors will be used after the ":syntax
reset" command.
For Unix you can use the file ~/.config/nvim/after/syntax/syncolor.vim.
Example: >
if &background == "light"
highlight comment ctermfg=darkgreen guifg=darkgreen
else
highlight comment ctermfg=green guifg=green
endif
*E679*
Do make sure this syncolor.vim script does not use a "syntax on", set the
'background' option or uses a "colorscheme" command, because it results in an
endless loop.
Note that when a color scheme is used, there might be some confusion whether
your defined colors are to be used or the colors from the scheme. This
depends on the color scheme file. See |:colorscheme|.
*syntax_cmd*
The "syntax_cmd" variable is set to one of these values when the
syntax/syncolor.vim files are loaded:
"on" ":syntax on" command. Highlight colors are overruled but
links are kept
"enable" ":syntax enable" command. Only define colors for groups that
don't have highlighting yet. Use ":syntax default".
"reset" ":syntax reset" command or loading a color scheme. Define all
the colors.
"skip" Don't define colors. Used to skip the default settings when a
syncolor.vim file earlier in 'runtimepath' has already set
them.
==============================================================================
16. Highlighting tags *tag-highlight*

View File

@ -358,6 +358,14 @@ Startup:
- works by default: "-" file is optional
- works in more cases: |-Es|, file args
Syntax highlighting:
syncolor.vim has been removed. Nvim now sets up default highlighting groups
automatically for both light and dark backgrounds, regardless of whether or
not syntax highlighting is enabled. This means that |:syntax-on| and
|:syntax-enable| are now identical. Users who previously used an
after/syntax/syncolor.vim file should transition that file into a
colorscheme. |:colorscheme|
TUI:
*:set-termcap*
Start Nvim with 'verbose' level 3 to show terminal capabilities: >

View File

@ -1,89 +0,0 @@
" Vim syntax support file
" Maintainer: Bram Moolenaar <Bram@vim.org>
" 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 <args>
command -nargs=* SynLink hi link <args>
else
if syntax_cmd == "enable"
" ":syntax enable" keeps any existing colors
command -nargs=* SynColor hi def <args>
command -nargs=* SynLink hi def link <args>
elseif syntax_cmd == "reset"
" ":syntax reset" resets all colors to the default
command -nargs=* SynColor hi <args>
command -nargs=* SynLink hi! link <args>
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

View File

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

View File

@ -372,11 +372,6 @@ int main(int argc, char **argv)
// 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`.

View File

@ -3416,16 +3416,6 @@ static void syn_cmd_on(exarg_T *eap, int syncing)
syn_cmd_onoff(eap, "syntax");
}
/*
* Handle ":syntax enable" command.
*/
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);
}
/*
* Handle ":syntax reset" command.
* It actually resets highlighting, not syntax.
@ -3434,9 +3424,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);
}
}
@ -3475,7 +3463,7 @@ void syn_maybe_enable(void)
exarg_T ea;
ea.arg = (char_u *)"";
ea.skip = false;
syn_cmd_enable(&ea, false);
syn_cmd_on(&ea, false);
}
}
@ -5534,7 +5522,7 @@ static struct subcommand subcommands[] =
{ "clear", syn_cmd_clear },
{ "cluster", syn_cmd_cluster },
{ "conceal", syn_cmd_conceal },
{ "enable", syn_cmd_enable },
{ "enable", syn_cmd_on },
{ "foldlevel", syn_cmd_foldlevel },
{ "include", syn_cmd_include },
{ "iskeyword", syn_cmd_iskeyword },
@ -6057,6 +6045,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 +6104,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 +6146,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 +6430,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);
}

View File

@ -14,6 +14,8 @@ local function new_screen(opt)
[3] = {bold = true, reverse = true},
[4] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
[5] = {bold = true, foreground = Screen.colors.SeaGreen4},
[6] = {foreground = Screen.colors.Magenta},
[7] = {bold = true, foreground = Screen.colors.Brown},
})
return screen
end
@ -267,7 +269,7 @@ local function test_cmdline(linegrid)
special = {'"', true},
}, {
firstc = "=",
content = {{"1"}, {"+"}, {"2"}},
content = {{"1", 6}, {"+", 7}, {"2", 6}},
pos = 3,
}}

View File

@ -789,7 +789,7 @@ describe("'listchars' highlight", function()
[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {background=Screen.colors.Grey90},
[2] = {foreground=Screen.colors.Red},
[3] = {foreground=Screen.colors.Green1},
[3] = {foreground=Screen.colors.X11Green, background=Screen.colors.Red1},
})
feed_command('highlight clear ModeMsg')
feed_command('highlight Whitespace guifg=#FF0000')

View File

@ -176,8 +176,8 @@ describe('Signs', function()
command('sign place 5 line=3 name=pietWarn buffer=1')
command('sign place 3 line=3 name=pietError buffer=1')
screen:expect([[
{1:>>}XX{6: 1 }a |
XX{1:>>}{6: 2 }b |
{1:>>}{8:XX}{6: 1 }a |
{8:XX}{1:>>}{6: 2 }b |
{1:>>}WW{6: 3 }c |
{2: }{6: 4 }^ |
{0:~ }|
@ -194,7 +194,7 @@ describe('Signs', function()
-- With the default setting, we get the sign with the top id.
command('set signcolumn=yes:1')
screen:expect([[
XX{6: 1 }a |
{8:XX}{6: 1 }a |
{1:>>}{6: 2 }b |
WW{6: 3 }c |
{2: }{6: 4 }^ |
@ -212,9 +212,9 @@ describe('Signs', function()
-- "auto:3" accommodates all the signs we defined so far.
command('set signcolumn=auto:3')
screen:expect([[
{1:>>}XX{2: }{6: 1 }a |
XX{1:>>}{2: }{6: 2 }b |
XX{1:>>}WW{6: 3 }c |
{1:>>}{8:XX}{2: }{6: 1 }a |
{8:XX}{1:>>}{2: }{6: 2 }b |
{8:XX}{1:>>}WW{6: 3 }c |
{2: }{6: 4 }^ |
{0:~ }|
{0:~ }|
@ -230,9 +230,9 @@ describe('Signs', function()
-- Check "yes:9".
command('set signcolumn=yes:9')
screen:expect([[
{1:>>}XX{2: }{6: 1 }a |
XX{1:>>}{2: }{6: 2 }b |
XX{1:>>}WW{2: }{6: 3 }c |
{1:>>}{8:XX}{2: }{6: 1 }a |
{8:XX}{1:>>}{2: }{6: 2 }b |
{8:XX}{1:>>}WW{2: }{6: 3 }c |
{2: }{6: 4 }^ |
{0:~ }|
{0:~ }|
@ -249,9 +249,9 @@ describe('Signs', function()
-- a single line (same result as "auto:3").
command('set signcolumn=auto:4')
screen:expect{grid=[[
{1:>>}XX{2: }{6: 1 }a |
XX{1:>>}{2: }{6: 2 }b |
XX{1:>>}WW{6: 3 }c |
{1:>>}{8:XX}{2: }{6: 1 }a |
{8:XX}{1:>>}{2: }{6: 2 }b |
{8:XX}{1:>>}WW{6: 3 }c |
{2: }{6: 4 }^ |
{0:~ }|
{0:~ }|
@ -267,8 +267,8 @@ describe('Signs', function()
-- line deletion deletes signs.
command('2d')
screen:expect([[
{1:>>}XX{2: }{6: 1 }a |
XX{1:>>}WW{6: 2 }^c |
{1:>>}{8:XX}{2: }{6: 1 }a |
{8:XX}{1:>>}WW{6: 2 }^c |
{2: }{6: 3 } |
{0:~ }|
{0:~ }|

View File

@ -52,6 +52,32 @@ local predefined_hl_defs = {
QuickFixLine=true,
Substitute=true,
Whitespace=true,
Error=true,
Todo=true,
String=true,
Character=true,
Number=true,
Boolean=true,
Float=true,
Function=true,
Conditional=true,
Repeat=true,
Label=true,
Operator=true,
Keyword=true,
Exception=true,
Include=true,
Define=true,
Macro=true,
PreCondit=true,
StorageClass=true,
Structure=true,
Typedef=true,
Tag=true,
SpecialChar=true,
Delimiter=true,
SpecialComment=true,
Debug=true,
-- From highlight_init_(dark|light)
ColorColumn=true,
@ -83,8 +109,6 @@ local predefined_hl_defs = {
Visual=true,
WarningMsg=true,
Normal=true,
-- From syncolor.vim, if &background
Comment=true,
Constant=true,
Special=true,
@ -94,36 +118,6 @@ local predefined_hl_defs = {
Type=true,
Underlined=true,
Ignore=true,
-- From syncolor.vim, below if &background
Error=true,
Todo=true,
-- From syncolor.vim, links at the bottom
String=true,
Character=true,
Number=true,
Boolean=true,
Float=true,
Function=true,
Conditional=true,
Repeat=true,
Label=true,
Operator=true,
Keyword=true,
Exception=true,
Include=true,
Define=true,
Macro=true,
PreCondit=true,
StorageClass=true,
Structure=true,
Typedef=true,
Tag=true,
SpecialChar=true,
Delimiter=true,
SpecialComment=true,
Debug=true,
}
local nvim_hl_defs = {}