mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 09:18:19 +00:00
syntax,viml/expressions/parser: Create defaults for expr highlighting
This commit is contained in:
@@ -5911,9 +5911,10 @@ static void ex_colorscheme(exarg_T *eap)
|
|||||||
|
|
||||||
static void ex_highlight(exarg_T *eap)
|
static void ex_highlight(exarg_T *eap)
|
||||||
{
|
{
|
||||||
if (*eap->arg == NUL && eap->cmd[2] == '!')
|
if (*eap->arg == NUL && eap->cmd[2] == '!') {
|
||||||
MSG(_("Greetings, Vim user!"));
|
MSG(_("Greetings, Vim user!"));
|
||||||
do_highlight(eap->arg, eap->forceit, FALSE);
|
}
|
||||||
|
do_highlight((const char *)eap->arg, eap->forceit, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -5929,8 +5929,7 @@ static void syntime_report(void)
|
|||||||
//
|
//
|
||||||
// When making changes here, also change runtime/colors/default.vim!
|
// When making changes here, also change runtime/colors/default.vim!
|
||||||
|
|
||||||
static char *highlight_init_both[] =
|
static const char *highlight_init_both[] = {
|
||||||
{
|
|
||||||
"Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey",
|
"Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey",
|
||||||
"Cursor guibg=fg guifg=bg",
|
"Cursor guibg=fg guifg=bg",
|
||||||
"lCursor guibg=fg guifg=bg",
|
"lCursor guibg=fg guifg=bg",
|
||||||
@@ -5954,8 +5953,7 @@ static char *highlight_init_both[] =
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *highlight_init_light[] =
|
static const char *highlight_init_light[] = {
|
||||||
{
|
|
||||||
"ColorColumn ctermbg=LightRed guibg=LightRed",
|
"ColorColumn ctermbg=LightRed guibg=LightRed",
|
||||||
"CursorColumn ctermbg=LightGrey guibg=Grey90",
|
"CursorColumn ctermbg=LightGrey guibg=Grey90",
|
||||||
"CursorLine cterm=underline guibg=Grey90",
|
"CursorLine cterm=underline guibg=Grey90",
|
||||||
@@ -5988,8 +5986,7 @@ static char *highlight_init_light[] =
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *highlight_init_dark[] =
|
static const char *highlight_init_dark[] = {
|
||||||
{
|
|
||||||
"ColorColumn ctermbg=DarkRed guibg=DarkRed",
|
"ColorColumn ctermbg=DarkRed guibg=DarkRed",
|
||||||
"CursorColumn ctermbg=DarkGrey guibg=Grey40",
|
"CursorColumn ctermbg=DarkGrey guibg=Grey40",
|
||||||
"CursorLine cterm=underline guibg=Grey40",
|
"CursorLine cterm=underline guibg=Grey40",
|
||||||
@@ -6022,6 +6019,157 @@ static char *highlight_init_dark[] =
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char *highlight_init_cmdline[] = {
|
||||||
|
// NVimInternalError should appear only when highlighter has a bug.
|
||||||
|
"NVimInternalError ctermfg=Red ctermbg=Red guifg=Red guibg=Red",
|
||||||
|
|
||||||
|
// Highlight groups (links) used by parser:
|
||||||
|
|
||||||
|
"default link NVimOperator Operator",
|
||||||
|
|
||||||
|
"default link NVimUnaryOperator NVimOperator",
|
||||||
|
"default link NVimUnaryPlus NVimUnaryOperator",
|
||||||
|
|
||||||
|
"default link NVimBinaryOperator NVimOperator",
|
||||||
|
"default link NVimComparison NVimBinaryOperator",
|
||||||
|
"default link NVimComparisonModifier NVimComparison",
|
||||||
|
"default link NVimBinaryPlus NVimBinaryOperator",
|
||||||
|
"default link NVimConcat NVimBinaryOperator",
|
||||||
|
"default link NVimConcatOrSubscript NVimConcat",
|
||||||
|
|
||||||
|
"default link NVimTernary NVimOperator",
|
||||||
|
"default link NVimTernaryColon NVimTernary",
|
||||||
|
|
||||||
|
"default link NVimParenthesis Delimiter",
|
||||||
|
"default link NVimLambda NVimParenthesis",
|
||||||
|
"default link NVimNestingParenthesis NVimParenthesis",
|
||||||
|
"default link NVimCallingParenthesis NVimParenthesis",
|
||||||
|
|
||||||
|
"default link NVimSubscript NVimParenthesis",
|
||||||
|
"default link NVimSubscriptBracket NVimSubscript",
|
||||||
|
"default link NVimSubscriptColon NVimSubscript",
|
||||||
|
"default link NVimSubscriptColon NVimSubscript",
|
||||||
|
"default link NVimCurly NVimSubscript",
|
||||||
|
|
||||||
|
"default link NVimContainer NVimParenthesis",
|
||||||
|
"default link NVimDict NVimContainer",
|
||||||
|
"default link NVimList NVimContainer",
|
||||||
|
|
||||||
|
"default link NVimIdentifier Identifier",
|
||||||
|
"default link NVimIdentifierScope NVimIdentifier",
|
||||||
|
"default link NVimIdentifierScopeDelimiter NVimIdentifier",
|
||||||
|
"default link NVimIdentifierName NVimIdentifier",
|
||||||
|
"default link NVimIdentifierKey NVimIdentifier",
|
||||||
|
|
||||||
|
"default link NVimColon Delimiter",
|
||||||
|
"default link NVimComma Delimiter",
|
||||||
|
"default link NVimArrow Delimiter",
|
||||||
|
|
||||||
|
"default link NVimRegister SpecialChar",
|
||||||
|
"default link NVimNumber Number",
|
||||||
|
"default link NVimFloat NVimNumber",
|
||||||
|
"default link NVimNumberPrefix SpecialChar",
|
||||||
|
|
||||||
|
"default link NVimString String",
|
||||||
|
"default link NVimStringBody NVimString",
|
||||||
|
"default link NVimStringQuote NVimString",
|
||||||
|
"default link NVimStringSpecial SpecialChar",
|
||||||
|
|
||||||
|
"default link NVimSingleQuote NVimStringQuote",
|
||||||
|
"default link NVimSingleQuotedBody NVimStringBody",
|
||||||
|
"default link NVimSingleQuotedQuote NVimStringSpecial",
|
||||||
|
|
||||||
|
"default link NVimDoubleQuote NVimStringQuote",
|
||||||
|
"default link NVimDoubleQuotedBody NVimStringBody",
|
||||||
|
"default link NVimDoubleQuotedEscape NVimStringSpecial",
|
||||||
|
// Not actually invalid, but we highlight user that he is doing something
|
||||||
|
// wrong.
|
||||||
|
"default link NVimDoubleQuotedUnknownEscape NVimInvalidValue",
|
||||||
|
|
||||||
|
"default link NVimFigureBrace NVimInternalError",
|
||||||
|
"default link NVimSingleQuotedUnknownEscape NVimInternalError",
|
||||||
|
|
||||||
|
// NVimInvalid groups:
|
||||||
|
|
||||||
|
"default link NVimInvalidSingleQuotedUnknownEscape NVimInternalError",
|
||||||
|
|
||||||
|
"default link NVimInvalid Error",
|
||||||
|
|
||||||
|
"default link NVimInvalidOperator NVimInvalid",
|
||||||
|
|
||||||
|
"default link NVimInvalidUnaryOperator NVimInvalidOperator",
|
||||||
|
"default link NVimInvalidUnaryPlus NVimInvalidUnaryOperator",
|
||||||
|
|
||||||
|
"default link NVimInvalidBinaryOperator NVimInvalidOperator",
|
||||||
|
"default link NVimInvalidComparison NVimInvalidBinaryOperator",
|
||||||
|
"default link NVimInvalidComparisonModifier NVimInvalidComparison",
|
||||||
|
"default link NVimInvalidBinaryPlus NVimInvalidBinaryOperator",
|
||||||
|
"default link NVimInvalidConcat NVimInvalidBinaryOperator",
|
||||||
|
"default link NVimInvalidConcatOrSubscript NVimInvalidConcat",
|
||||||
|
|
||||||
|
"default link NVimInvalidTernary NVimInvalidOperator",
|
||||||
|
"default link NVimInvalidTernaryColon NVimInvalidTernary",
|
||||||
|
|
||||||
|
"default link NVimInvalidDelimiter NVimInvalid",
|
||||||
|
|
||||||
|
"default link NVimInvalidParenthesis NVimInvalidDelimiter",
|
||||||
|
"default link NVimInvalidLambda NVimInvalidParenthesis",
|
||||||
|
"default link NVimInvalidNestingParenthesis NVimInvalidParenthesis",
|
||||||
|
"default link NVimInvalidCallingParenthesis NVimInvalidParenthesis",
|
||||||
|
|
||||||
|
"default link NVimInvalidSubscript NVimInvalidParenthesis",
|
||||||
|
"default link NVimInvalidSubscriptBracket NVimInvalidSubscript",
|
||||||
|
"default link NVimInvalidSubscriptColon NVimInvalidSubscript",
|
||||||
|
"default link NVimInvalidSubscriptColon NVimInvalidSubscript",
|
||||||
|
"default link NVimInvalidCurly NVimInvalidSubscript",
|
||||||
|
|
||||||
|
"default link NVimInvalidContainer NVimInvalidParenthesis",
|
||||||
|
"default link NVimInvalidDict NVimInvalidContainer",
|
||||||
|
"default link NVimInvalidList NVimInvalidContainer",
|
||||||
|
|
||||||
|
"default link NVimInvalidIdentifier Identifier",
|
||||||
|
"default link NVimInvalidIdentifierScope NVimIdentifier",
|
||||||
|
"default link NVimInvalidIdentifierScopeDelimiter NVimIdentifier",
|
||||||
|
"default link NVimInvalidIdentifierName NVimIdentifier",
|
||||||
|
"default link NVimInvalidIdentifierKey NVimIdentifier",
|
||||||
|
|
||||||
|
"default link NVimInvalidColon NVimInvalidDelimiter",
|
||||||
|
"default link NVimInvalidComma NVimInvalidDelimiter",
|
||||||
|
"default link NVimInvalidArrow NVimInvalidDelimiter",
|
||||||
|
|
||||||
|
"default link NVimInvalidValue NVimInvalid",
|
||||||
|
|
||||||
|
"default link NVimInvalidRegister NVimInvalidValue",
|
||||||
|
"default link NVimInvalidNumber NVimInvalidValue",
|
||||||
|
"default link NVimInvalidFloat NVimInvalidNumber",
|
||||||
|
"default link NVimInvalidNumberPrefix NVimInvalidNumber",
|
||||||
|
|
||||||
|
// Invalid string bodies and specials are still highlighted as valid ones to
|
||||||
|
// minimize the red area.
|
||||||
|
"default link NVimInvalidString NVimInvalidValue",
|
||||||
|
"default link NVimInvalidStringBody NVimString",
|
||||||
|
"default link NVimInvalidStringQuote NVimInvalidString",
|
||||||
|
"default link NVimInvalidStringSpecial NVimStringSpecial",
|
||||||
|
|
||||||
|
"default link NVimInvalidSingleQuote NVimInvalidStringQuote",
|
||||||
|
"default link NVimInvalidSingleQuotedBody NVimInvalidStringBody",
|
||||||
|
"default link NVimInvalidSingleQuotedQuote NVimInvalidStringSpecial",
|
||||||
|
|
||||||
|
"default link NVimInvalidDoubleQuote NVimInvalidStringQuote",
|
||||||
|
"default link NVimInvalidDoubleQuotedBody NVimInvalidStringBody",
|
||||||
|
"default link NVimInvalidDoubleQuotedEscape NVimInvalidStringSpecial",
|
||||||
|
"default link NVimInvalidDoubleQuotedUnknownEscape NVimInvalidValue",
|
||||||
|
|
||||||
|
"default link NVimInvalidFigureBrace NVimInternalError",
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Create default links for NVim* highlight groups used for cmdline coloring
|
||||||
|
void syn_init_cmdline_highlight(bool reset, bool init)
|
||||||
|
{
|
||||||
|
for (size_t i = 0 ; i < ARRAY_SIZE(highlight_init_cmdline) ; i++) {
|
||||||
|
do_highlight(highlight_init_cmdline[i], reset, init);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Load colors from a file if "g:colors_name" is set, otherwise load builtin
|
/// Load colors from a file if "g:colors_name" is set, otherwise load builtin
|
||||||
/// colors
|
/// colors
|
||||||
@@ -6032,7 +6180,6 @@ void
|
|||||||
init_highlight(int both, int reset)
|
init_highlight(int both, int reset)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char **pp;
|
|
||||||
static int had_both = FALSE;
|
static int had_both = FALSE;
|
||||||
|
|
||||||
// Try finding the color scheme file. Used when a color file was loaded
|
// Try finding the color scheme file. Used when a color file was loaded
|
||||||
@@ -6054,9 +6201,9 @@ init_highlight(int both, int reset)
|
|||||||
*/
|
*/
|
||||||
if (both) {
|
if (both) {
|
||||||
had_both = TRUE;
|
had_both = TRUE;
|
||||||
pp = highlight_init_both;
|
const char *const *const pp = highlight_init_both;
|
||||||
for (i = 0; pp[i] != NULL; i++) {
|
for (i = 0; pp[i] != NULL; i++) {
|
||||||
do_highlight((char_u *)pp[i], reset, true);
|
do_highlight(pp[i], reset, true);
|
||||||
}
|
}
|
||||||
} else if (!had_both) {
|
} else if (!had_both) {
|
||||||
// Don't do anything before the call with both == TRUE from main().
|
// Don't do anything before the call with both == TRUE from main().
|
||||||
@@ -6065,10 +6212,11 @@ init_highlight(int both, int reset)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pp = (*p_bg == 'l') ? highlight_init_light : highlight_init_dark;
|
const char *const *const pp = ((*p_bg == 'l')
|
||||||
|
? highlight_init_light
|
||||||
|
: highlight_init_dark);
|
||||||
for (i = 0; pp[i] != NULL; i++) {
|
for (i = 0; pp[i] != NULL; i++) {
|
||||||
do_highlight((char_u *)pp[i], reset, true);
|
do_highlight(pp[i], reset, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reverse looks ugly, but grey may not work for 8 colors. Thus let it
|
/* Reverse looks ugly, but grey may not work for 8 colors. Thus let it
|
||||||
@@ -6078,15 +6226,13 @@ init_highlight(int both, int reset)
|
|||||||
* Clear the attributes, needed when changing the t_Co value. */
|
* Clear the attributes, needed when changing the t_Co value. */
|
||||||
if (t_colors > 8) {
|
if (t_colors > 8) {
|
||||||
do_highlight(
|
do_highlight(
|
||||||
(char_u *)(*p_bg == 'l'
|
(*p_bg == 'l'
|
||||||
? "Visual cterm=NONE ctermbg=LightGrey"
|
? "Visual cterm=NONE ctermbg=LightGrey"
|
||||||
: "Visual cterm=NONE ctermbg=DarkGrey"), false,
|
: "Visual cterm=NONE ctermbg=DarkGrey"), false, true);
|
||||||
true);
|
|
||||||
} else {
|
} else {
|
||||||
do_highlight((char_u *)"Visual cterm=reverse ctermbg=NONE",
|
do_highlight("Visual cterm=reverse ctermbg=NONE", false, true);
|
||||||
FALSE, TRUE);
|
|
||||||
if (*p_bg == 'l')
|
if (*p_bg == 'l')
|
||||||
do_highlight((char_u *)"Search ctermfg=black", FALSE, TRUE);
|
do_highlight("Search ctermfg=black", false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -6102,6 +6248,10 @@ init_highlight(int both, int reset)
|
|||||||
(void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL);
|
(void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL);
|
||||||
recursive--;
|
recursive--;
|
||||||
}
|
}
|
||||||
|
// Without syncolor.vim it is going to screw everything over by defining
|
||||||
|
// cleared highlight groups by creating links to non-existent groups. This
|
||||||
|
// effectively prevents ":highlight default" from working properly.
|
||||||
|
syn_init_cmdline_highlight(reset, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6137,17 +6287,22 @@ int load_colors(char_u *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Handle the ":highlight .." command.
|
/// Handle ":highlight" command
|
||||||
/// When using ":hi clear" this is called recursively for each group with
|
///
|
||||||
/// "forceit" and "init" both TRUE.
|
/// When using ":highlight clear" this is called recursively for each group with
|
||||||
/// @param init TRUE when called for initializing
|
/// forceit and init being both true.
|
||||||
void
|
///
|
||||||
do_highlight(char_u *line, int forceit, int init) {
|
/// @param[in] line Command arguments.
|
||||||
char_u *name_end;
|
/// @param[in] forceit True when bang is given, allows to link group even if
|
||||||
char_u *linep;
|
/// it has its own settings.
|
||||||
char_u *key_start;
|
/// @param[in] init True when initializing.
|
||||||
char_u *arg_start;
|
void do_highlight(const char *line, const bool forceit, const bool init)
|
||||||
char_u *key = NULL, *arg = NULL;
|
FUNC_ATTR_NONNULL_ALL
|
||||||
|
{
|
||||||
|
const char *name_end;
|
||||||
|
const char *linep;
|
||||||
|
const char *key_start;
|
||||||
|
const char *arg_start;
|
||||||
long i;
|
long i;
|
||||||
int off;
|
int off;
|
||||||
int len;
|
int len;
|
||||||
@@ -6161,94 +6316,87 @@ do_highlight(char_u *line, int forceit, int init) {
|
|||||||
int color;
|
int color;
|
||||||
bool is_normal_group = false; // "Normal" group
|
bool is_normal_group = false; // "Normal" group
|
||||||
|
|
||||||
/*
|
// If no argument, list current highlighting.
|
||||||
* If no argument, list current highlighting.
|
if (ends_excmd((uint8_t)(*line))) {
|
||||||
*/
|
|
||||||
if (ends_excmd(*line)) {
|
|
||||||
for (int i = 1; i <= highlight_ga.ga_len && !got_int; i++) {
|
for (int i = 1; i <= highlight_ga.ga_len && !got_int; i++) {
|
||||||
// todo(vim): only call when the group has attributes set
|
// TODO(brammool): only call when the group has attributes set
|
||||||
highlight_list_one(i);
|
highlight_list_one(i);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Isolate the name.
|
||||||
* Isolate the name.
|
name_end = (const char *)skiptowhite((const char_u *)line);
|
||||||
*/
|
linep = (const char *)skipwhite((const char_u *)name_end);
|
||||||
name_end = skiptowhite(line);
|
|
||||||
linep = skipwhite(name_end);
|
|
||||||
|
|
||||||
/*
|
// Check for "default" argument.
|
||||||
* Check for "default" argument.
|
if (strncmp(line, "default", name_end - line) == 0) {
|
||||||
*/
|
dodefault = true;
|
||||||
if (STRNCMP(line, "default", name_end - line) == 0) {
|
|
||||||
dodefault = TRUE;
|
|
||||||
line = linep;
|
line = linep;
|
||||||
name_end = skiptowhite(line);
|
name_end = (const char *)skiptowhite((const char_u *)line);
|
||||||
linep = skipwhite(name_end);
|
linep = (const char *)skipwhite((const char_u *)name_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Check for "clear" or "link" argument.
|
||||||
* Check for "clear" or "link" argument.
|
if (strncmp(line, "clear", name_end - line) == 0) {
|
||||||
*/
|
doclear = true;
|
||||||
if (STRNCMP(line, "clear", name_end - line) == 0)
|
} else if (strncmp(line, "link", name_end - line) == 0) {
|
||||||
doclear = TRUE;
|
dolink = true;
|
||||||
if (STRNCMP(line, "link", name_end - line) == 0)
|
}
|
||||||
dolink = TRUE;
|
|
||||||
|
|
||||||
/*
|
// ":highlight {group-name}": list highlighting for one group.
|
||||||
* ":highlight {group-name}": list highlighting for one group.
|
if (!doclear && !dolink && ends_excmd((uint8_t)(*linep))) {
|
||||||
*/
|
id = syn_namen2id((const char_u *)line, (int)(name_end - line));
|
||||||
if (!doclear && !dolink && ends_excmd(*linep)) {
|
if (id == 0) {
|
||||||
id = syn_namen2id(line, (int)(name_end - line));
|
emsgf(_("E411: highlight group not found: %s"), line);
|
||||||
if (id == 0)
|
} else {
|
||||||
EMSG2(_("E411: highlight group not found: %s"), line);
|
|
||||||
else
|
|
||||||
highlight_list_one(id);
|
highlight_list_one(id);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Handle ":highlight link {from} {to}" command.
|
||||||
* Handle ":highlight link {from} {to}" command.
|
|
||||||
*/
|
|
||||||
if (dolink) {
|
if (dolink) {
|
||||||
char_u *from_start = linep;
|
const char *from_start = linep;
|
||||||
char_u *from_end;
|
const char *from_end;
|
||||||
char_u *to_start;
|
const char *to_start;
|
||||||
char_u *to_end;
|
const char *to_end;
|
||||||
int from_id;
|
int from_id;
|
||||||
int to_id;
|
int to_id;
|
||||||
|
|
||||||
from_end = skiptowhite(from_start);
|
from_end = (const char *)skiptowhite((const char_u *)from_start);
|
||||||
to_start = skipwhite(from_end);
|
to_start = (const char *)skipwhite((const char_u *)from_end);
|
||||||
to_end = skiptowhite(to_start);
|
to_end = (const char *)skiptowhite((const char_u *)to_start);
|
||||||
|
|
||||||
if (ends_excmd(*from_start) || ends_excmd(*to_start)) {
|
if (ends_excmd((uint8_t)(*from_start))
|
||||||
EMSG2(_("E412: Not enough arguments: \":highlight link %s\""),
|
|| ends_excmd((uint8_t)(*to_start))) {
|
||||||
|
emsgf(_("E412: Not enough arguments: \":highlight link %s\""),
|
||||||
from_start);
|
from_start);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ends_excmd(*skipwhite(to_end))) {
|
if (!ends_excmd(*skipwhite((const char_u *)to_end))) {
|
||||||
EMSG2(_("E413: Too many arguments: \":highlight link %s\""), from_start);
|
emsgf(_("E413: Too many arguments: \":highlight link %s\""), from_start);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
from_id = syn_check_group(from_start, (int)(from_end - from_start));
|
from_id = syn_check_group((const char_u *)from_start,
|
||||||
if (STRNCMP(to_start, "NONE", 4) == 0)
|
(int)(from_end - from_start));
|
||||||
|
if (strncmp(to_start, "NONE", 4) == 0) {
|
||||||
to_id = 0;
|
to_id = 0;
|
||||||
else
|
} else {
|
||||||
to_id = syn_check_group(to_start, (int)(to_end - to_start));
|
to_id = syn_check_group((const char_u *)to_start,
|
||||||
|
(int)(to_end - to_start));
|
||||||
|
}
|
||||||
|
|
||||||
if (from_id > 0 && (!init || HL_TABLE()[from_id - 1].sg_set == 0)) {
|
if (from_id > 0 && (!init || HL_TABLE()[from_id - 1].sg_set == 0)) {
|
||||||
/*
|
// Don't allow a link when there already is some highlighting
|
||||||
* Don't allow a link when there already is some highlighting
|
// for the group, unless '!' is used
|
||||||
* for the group, unless '!' is used
|
|
||||||
*/
|
|
||||||
if (to_id > 0 && !forceit && !init
|
if (to_id > 0 && !forceit && !init
|
||||||
&& hl_has_settings(from_id - 1, dodefault)) {
|
&& hl_has_settings(from_id - 1, dodefault)) {
|
||||||
if (sourcing_name == NULL && !dodefault)
|
if (sourcing_name == NULL && !dodefault) {
|
||||||
EMSG(_("E414: group has settings, highlight link ignored"));
|
EMSG(_("E414: group has settings, highlight link ignored"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!init)
|
if (!init)
|
||||||
HL_TABLE()[from_id - 1].sg_set |= SG_LINK;
|
HL_TABLE()[from_id - 1].sg_set |= SG_LINK;
|
||||||
@@ -6258,43 +6406,38 @@ do_highlight(char_u *line, int forceit, int init) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only call highlight_changed() once, after sourcing a syntax file */
|
// Only call highlight_changed() once, after sourcing a syntax file.
|
||||||
need_highlight_changed = TRUE;
|
need_highlight_changed = true;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doclear) {
|
if (doclear) {
|
||||||
/*
|
// ":highlight clear [group]" command.
|
||||||
* ":highlight clear [group]" command.
|
|
||||||
*/
|
|
||||||
line = linep;
|
line = linep;
|
||||||
if (ends_excmd(*line)) {
|
if (ends_excmd((uint8_t)(*line))) {
|
||||||
do_unlet(S_LEN("colors_name"), true);
|
do_unlet(S_LEN("colors_name"), true);
|
||||||
restore_cterm_colors();
|
restore_cterm_colors();
|
||||||
|
|
||||||
/*
|
// Clear all default highlight groups and load the defaults.
|
||||||
* Clear all default highlight groups and load the defaults.
|
|
||||||
*/
|
|
||||||
for (int idx = 0; idx < highlight_ga.ga_len; ++idx) {
|
for (int idx = 0; idx < highlight_ga.ga_len; ++idx) {
|
||||||
highlight_clear(idx);
|
highlight_clear(idx);
|
||||||
}
|
}
|
||||||
init_highlight(TRUE, TRUE);
|
init_highlight(true, true);
|
||||||
highlight_changed();
|
highlight_changed();
|
||||||
redraw_later_clear();
|
redraw_later_clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
name_end = skiptowhite(line);
|
name_end = (const char *)skiptowhite((const char_u *)line);
|
||||||
linep = skipwhite(name_end);
|
linep = (const char *)skipwhite((const char_u *)name_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Find the group name in the table. If it does not exist yet, add it.
|
||||||
* Find the group name in the table. If it does not exist yet, add it.
|
id = syn_check_group((const char_u *)line, (int)(name_end - line));
|
||||||
*/
|
if (id == 0) { // Failed (out of memory).
|
||||||
id = syn_check_group(line, (int)(name_end - line));
|
|
||||||
if (id == 0) /* failed (out of memory) */
|
|
||||||
return;
|
return;
|
||||||
idx = id - 1; /* index is ID minus one */
|
}
|
||||||
|
idx = id - 1; // Index is ID minus one.
|
||||||
|
|
||||||
// Return if "default" was used and the group already has settings
|
// Return if "default" was used and the group already has settings
|
||||||
if (dodefault && hl_has_settings(idx, true)) {
|
if (dodefault && hl_has_settings(idx, true)) {
|
||||||
@@ -6303,19 +6446,21 @@ do_highlight(char_u *line, int forceit, int init) {
|
|||||||
|
|
||||||
is_normal_group = (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0);
|
is_normal_group = (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0);
|
||||||
|
|
||||||
/* Clear the highlighting for ":hi clear {group}" and ":hi clear". */
|
// Clear the highlighting for ":hi clear {group}" and ":hi clear".
|
||||||
if (doclear || (forceit && init)) {
|
if (doclear || (forceit && init)) {
|
||||||
highlight_clear(idx);
|
highlight_clear(idx);
|
||||||
if (!doclear)
|
if (!doclear)
|
||||||
HL_TABLE()[idx].sg_set = 0;
|
HL_TABLE()[idx].sg_set = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *key = NULL;
|
||||||
|
char *arg = NULL;
|
||||||
if (!doclear) {
|
if (!doclear) {
|
||||||
while (!ends_excmd(*linep)) {
|
while (!ends_excmd((uint8_t)(*linep))) {
|
||||||
key_start = linep;
|
key_start = linep;
|
||||||
if (*linep == '=') {
|
if (*linep == '=') {
|
||||||
EMSG2(_("E415: unexpected equal sign: %s"), key_start);
|
emsgf(_("E415: unexpected equal sign: %s"), key_start);
|
||||||
error = TRUE;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6325,61 +6470,58 @@ do_highlight(char_u *line, int forceit, int init) {
|
|||||||
linep++;
|
linep++;
|
||||||
}
|
}
|
||||||
xfree(key);
|
xfree(key);
|
||||||
key = vim_strnsave_up(key_start, (int)(linep - key_start));
|
key = (char *)vim_strnsave_up((const char_u *)key_start,
|
||||||
linep = skipwhite(linep);
|
(int)(linep - key_start));
|
||||||
|
linep = (const char *)skipwhite((const char_u *)linep);
|
||||||
|
|
||||||
if (STRCMP(key, "NONE") == 0) {
|
if (strcmp(key, "NONE") == 0) {
|
||||||
if (!init || HL_TABLE()[idx].sg_set == 0) {
|
if (!init || HL_TABLE()[idx].sg_set == 0) {
|
||||||
if (!init)
|
if (!init) {
|
||||||
HL_TABLE()[idx].sg_set |= SG_CTERM+SG_GUI;
|
HL_TABLE()[idx].sg_set |= SG_CTERM+SG_GUI;
|
||||||
|
}
|
||||||
highlight_clear(idx);
|
highlight_clear(idx);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Check for the equal sign.
|
||||||
* Check for the equal sign.
|
|
||||||
*/
|
|
||||||
if (*linep != '=') {
|
if (*linep != '=') {
|
||||||
EMSG2(_("E416: missing equal sign: %s"), key_start);
|
emsgf(_("E416: missing equal sign: %s"), key_start);
|
||||||
error = TRUE;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++linep;
|
linep++;
|
||||||
|
|
||||||
/*
|
// Isolate the argument.
|
||||||
* Isolate the argument.
|
linep = (const char *)skipwhite((const char_u *)linep);
|
||||||
*/
|
if (*linep == '\'') { // guifg='color name'
|
||||||
linep = skipwhite(linep);
|
|
||||||
if (*linep == '\'') { /* guifg='color name' */
|
|
||||||
arg_start = ++linep;
|
arg_start = ++linep;
|
||||||
linep = vim_strchr(linep, '\'');
|
linep = strchr(linep, '\'');
|
||||||
if (linep == NULL) {
|
if (linep == NULL) {
|
||||||
EMSG2(_(e_invarg2), key_start);
|
emsgf(_(e_invarg2), key_start);
|
||||||
error = TRUE;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
arg_start = linep;
|
arg_start = linep;
|
||||||
linep = skiptowhite(linep);
|
linep = (const char *)skiptowhite((const char_u *)linep);
|
||||||
}
|
}
|
||||||
if (linep == arg_start) {
|
if (linep == arg_start) {
|
||||||
EMSG2(_("E417: missing argument: %s"), key_start);
|
emsgf(_("E417: missing argument: %s"), key_start);
|
||||||
error = TRUE;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
xfree(arg);
|
xfree(arg);
|
||||||
arg = vim_strnsave(arg_start, (int)(linep - arg_start));
|
arg = xstrndup(arg_start, (size_t)(linep - arg_start));
|
||||||
|
|
||||||
if (*linep == '\'')
|
if (*linep == '\'') {
|
||||||
++linep;
|
linep++;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
// Store the argument.
|
||||||
* Store the argument.
|
if (strcmp(key, "TERM") == 0
|
||||||
*/
|
|| strcmp(key, "CTERM") == 0
|
||||||
if ( STRCMP(key, "TERM") == 0
|
|| strcmp(key, "GUI") == 0) {
|
||||||
|| STRCMP(key, "CTERM") == 0
|
|
||||||
|| STRCMP(key, "GUI") == 0) {
|
|
||||||
attr = 0;
|
attr = 0;
|
||||||
off = 0;
|
off = 0;
|
||||||
while (arg[off] != NUL) {
|
while (arg[off] != NUL) {
|
||||||
@@ -6392,26 +6534,30 @@ do_highlight(char_u *line, int forceit, int init) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
EMSG2(_("E418: Illegal value: %s"), arg);
|
emsgf(_("E418: Illegal value: %s"), arg);
|
||||||
error = TRUE;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (arg[off] == ',') /* another one follows */
|
if (arg[off] == ',') { // Another one follows.
|
||||||
++off;
|
off++;
|
||||||
}
|
}
|
||||||
if (error)
|
}
|
||||||
|
if (error) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (*key == 'C') {
|
if (*key == 'C') {
|
||||||
if (!init || !(HL_TABLE()[idx].sg_set & SG_CTERM)) {
|
if (!init || !(HL_TABLE()[idx].sg_set & SG_CTERM)) {
|
||||||
if (!init)
|
if (!init) {
|
||||||
HL_TABLE()[idx].sg_set |= SG_CTERM;
|
HL_TABLE()[idx].sg_set |= SG_CTERM;
|
||||||
|
}
|
||||||
HL_TABLE()[idx].sg_cterm = attr;
|
HL_TABLE()[idx].sg_cterm = attr;
|
||||||
HL_TABLE()[idx].sg_cterm_bold = FALSE;
|
HL_TABLE()[idx].sg_cterm_bold = FALSE;
|
||||||
}
|
}
|
||||||
} else if (*key == 'G') {
|
} else if (*key == 'G') {
|
||||||
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) {
|
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) {
|
||||||
if (!init)
|
if (!init) {
|
||||||
HL_TABLE()[idx].sg_set |= SG_GUI;
|
HL_TABLE()[idx].sg_set |= SG_GUI;
|
||||||
|
}
|
||||||
HL_TABLE()[idx].sg_gui = attr;
|
HL_TABLE()[idx].sg_gui = attr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6430,14 +6576,14 @@ do_highlight(char_u *line, int forceit, int init) {
|
|||||||
HL_TABLE()[idx].sg_cterm_bold = FALSE;
|
HL_TABLE()[idx].sg_cterm_bold = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ascii_isdigit(*arg))
|
if (ascii_isdigit(*arg)) {
|
||||||
color = atoi((char *)arg);
|
color = atoi((char *)arg);
|
||||||
else if (STRICMP(arg, "fg") == 0) {
|
} else if (STRICMP(arg, "fg") == 0) {
|
||||||
if (cterm_normal_fg_color)
|
if (cterm_normal_fg_color) {
|
||||||
color = cterm_normal_fg_color - 1;
|
color = cterm_normal_fg_color - 1;
|
||||||
else {
|
} else {
|
||||||
EMSG(_("E419: FG color unknown"));
|
EMSG(_("E419: FG color unknown"));
|
||||||
error = TRUE;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (STRICMP(arg, "bg") == 0) {
|
} else if (STRICMP(arg, "bg") == 0) {
|
||||||
@@ -6445,70 +6591,85 @@ do_highlight(char_u *line, int forceit, int init) {
|
|||||||
color = cterm_normal_bg_color - 1;
|
color = cterm_normal_bg_color - 1;
|
||||||
else {
|
else {
|
||||||
EMSG(_("E420: BG color unknown"));
|
EMSG(_("E420: BG color unknown"));
|
||||||
error = TRUE;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
static char *(color_names[28]) = {
|
static const char *color_names[] = {
|
||||||
"Black", "DarkBlue", "DarkGreen", "DarkCyan",
|
"Black", "DarkBlue", "DarkGreen", "DarkCyan",
|
||||||
"DarkRed", "DarkMagenta", "Brown", "DarkYellow",
|
"DarkRed", "DarkMagenta", "Brown", "DarkYellow",
|
||||||
"Gray", "Grey",
|
"Gray", "Grey",
|
||||||
"LightGray", "LightGrey", "DarkGray", "DarkGrey",
|
"LightGray", "LightGrey", "DarkGray", "DarkGrey",
|
||||||
"Blue", "LightBlue", "Green", "LightGreen",
|
"Blue", "LightBlue", "Green", "LightGreen",
|
||||||
"Cyan", "LightCyan", "Red", "LightRed", "Magenta",
|
"Cyan", "LightCyan", "Red", "LightRed", "Magenta",
|
||||||
"LightMagenta", "Yellow", "LightYellow", "White", "NONE"
|
"LightMagenta", "Yellow", "LightYellow", "White",
|
||||||
|
"NONE"
|
||||||
};
|
};
|
||||||
static int color_numbers_16[28] = {0, 1, 2, 3,
|
static const int color_numbers_16[] = {
|
||||||
|
0, 1, 2, 3,
|
||||||
4, 5, 6, 6,
|
4, 5, 6, 6,
|
||||||
7, 7,
|
7, 7,
|
||||||
7, 7, 8, 8,
|
7, 7, 8, 8,
|
||||||
9, 9, 10, 10,
|
9, 9, 10, 10,
|
||||||
11, 11, 12, 12, 13,
|
11, 11, 12, 12, 13,
|
||||||
13, 14, 14, 15, -1};
|
13, 14, 14, 15,
|
||||||
/* for xterm with 88 colors... */
|
-1
|
||||||
static int color_numbers_88[28] = {0, 4, 2, 6,
|
};
|
||||||
|
// For xterm with 88 colors:
|
||||||
|
static int color_numbers_88[] = {
|
||||||
|
0, 4, 2, 6,
|
||||||
1, 5, 32, 72,
|
1, 5, 32, 72,
|
||||||
84, 84,
|
84, 84,
|
||||||
7, 7, 82, 82,
|
7, 7, 82, 82,
|
||||||
12, 43, 10, 61,
|
12, 43, 10, 61,
|
||||||
14, 63, 9, 74, 13,
|
14, 63, 9, 74, 13,
|
||||||
75, 11, 78, 15, -1};
|
75, 11, 78, 15,
|
||||||
/* for xterm with 256 colors... */
|
-1
|
||||||
static int color_numbers_256[28] = {0, 4, 2, 6,
|
};
|
||||||
|
// For xterm with 256 colors:
|
||||||
|
static int color_numbers_256[] = {
|
||||||
|
0, 4, 2, 6,
|
||||||
1, 5, 130, 130,
|
1, 5, 130, 130,
|
||||||
248, 248,
|
248, 248,
|
||||||
7, 7, 242, 242,
|
7, 7, 242, 242,
|
||||||
12, 81, 10, 121,
|
12, 81, 10, 121,
|
||||||
14, 159, 9, 224, 13,
|
14, 159, 9, 224, 13,
|
||||||
225, 11, 229, 15, -1};
|
225, 11, 229, 15,
|
||||||
/* for terminals with less than 16 colors... */
|
-1
|
||||||
static int color_numbers_8[28] = {0, 4, 2, 6,
|
};
|
||||||
|
// For terminals with less than 16 colors:
|
||||||
|
static int color_numbers_8[28] = {
|
||||||
|
0, 4, 2, 6,
|
||||||
1, 5, 3, 3,
|
1, 5, 3, 3,
|
||||||
7, 7,
|
7, 7,
|
||||||
7, 7, 0+8, 0+8,
|
7, 7, 0+8, 0+8,
|
||||||
4+8, 4+8, 2+8, 2+8,
|
4+8, 4+8, 2+8, 2+8,
|
||||||
6+8, 6+8, 1+8, 1+8, 5+8,
|
6+8, 6+8, 1+8, 1+8, 5+8,
|
||||||
5+8, 3+8, 3+8, 7+8, -1};
|
5+8, 3+8, 3+8, 7+8,
|
||||||
|
-1
|
||||||
|
};
|
||||||
|
|
||||||
/* reduce calls to STRICMP a bit, it can be slow */
|
// Reduce calls to STRICMP a bit, it can be slow.
|
||||||
off = TOUPPER_ASC(*arg);
|
off = TOUPPER_ASC(*arg);
|
||||||
for (i = ARRAY_SIZE(color_names); --i >= 0; )
|
for (i = ARRAY_SIZE(color_names); --i >= 0; ) {
|
||||||
if (off == color_names[i][0]
|
if (off == color_names[i][0]
|
||||||
&& STRICMP(arg + 1, color_names[i] + 1) == 0)
|
&& STRICMP(arg + 1, color_names[i] + 1) == 0) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
EMSG2(_(
|
emsgf(_(
|
||||||
"E421: Color name or number not recognized: %s"),
|
"E421: Color name or number not recognized: %s"),
|
||||||
key_start);
|
key_start);
|
||||||
error = TRUE;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use the _16 table to check if its a valid color name. */
|
// Use the _16 table to check if its a valid color name.
|
||||||
color = color_numbers_16[i];
|
color = color_numbers_16[i];
|
||||||
if (color >= 0) {
|
if (color >= 0) {
|
||||||
if (t_colors == 8) {
|
if (t_colors == 8) {
|
||||||
/* t_Co is 8: use the 8 colors table */
|
// t_Co is 8: use the 8 colors table.
|
||||||
color = color_numbers_8[i];
|
color = color_numbers_8[i];
|
||||||
if (key[5] == 'F') {
|
if (key[5] == 'F') {
|
||||||
/* set/reset bold attribute to get light foreground
|
/* set/reset bold attribute to get light foreground
|
||||||
@@ -6532,17 +6693,15 @@ do_highlight(char_u *line, int forceit, int init) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Add one to the argument, to avoid zero. Zero is used for
|
// Add one to the argument, to avoid zero. Zero is used for
|
||||||
* "NONE", then "color" is -1. */
|
// "NONE", then "color" is -1.
|
||||||
if (key[5] == 'F') {
|
if (key[5] == 'F') {
|
||||||
HL_TABLE()[idx].sg_cterm_fg = color + 1;
|
HL_TABLE()[idx].sg_cterm_fg = color + 1;
|
||||||
if (is_normal_group) {
|
if (is_normal_group) {
|
||||||
cterm_normal_fg_color = color + 1;
|
cterm_normal_fg_color = color + 1;
|
||||||
cterm_normal_fg_bold = (HL_TABLE()[idx].sg_cterm & HL_BOLD);
|
cterm_normal_fg_bold = (HL_TABLE()[idx].sg_cterm & HL_BOLD);
|
||||||
{
|
|
||||||
must_redraw = CLEAR;
|
must_redraw = CLEAR;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
HL_TABLE()[idx].sg_cterm_bg = color + 1;
|
HL_TABLE()[idx].sg_cterm_bg = color + 1;
|
||||||
if (is_normal_group) {
|
if (is_normal_group) {
|
||||||
@@ -6565,15 +6724,15 @@ do_highlight(char_u *line, int forceit, int init) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (STRCMP(key, "GUIFG") == 0) {
|
} else if (strcmp(key, "GUIFG") == 0) {
|
||||||
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) {
|
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) {
|
||||||
if (!init)
|
if (!init)
|
||||||
HL_TABLE()[idx].sg_set |= SG_GUI;
|
HL_TABLE()[idx].sg_set |= SG_GUI;
|
||||||
|
|
||||||
xfree(HL_TABLE()[idx].sg_rgb_fg_name);
|
xfree(HL_TABLE()[idx].sg_rgb_fg_name);
|
||||||
if (STRCMP(arg, "NONE")) {
|
if (strcmp(arg, "NONE")) {
|
||||||
HL_TABLE()[idx].sg_rgb_fg_name = (uint8_t *)xstrdup((char *)arg);
|
HL_TABLE()[idx].sg_rgb_fg_name = (char_u *)xstrdup((char *)arg);
|
||||||
HL_TABLE()[idx].sg_rgb_fg = name_to_color(arg);
|
HL_TABLE()[idx].sg_rgb_fg = name_to_color((const char_u *)arg);
|
||||||
} else {
|
} else {
|
||||||
HL_TABLE()[idx].sg_rgb_fg_name = NULL;
|
HL_TABLE()[idx].sg_rgb_fg_name = NULL;
|
||||||
HL_TABLE()[idx].sg_rgb_fg = -1;
|
HL_TABLE()[idx].sg_rgb_fg = -1;
|
||||||
@@ -6590,8 +6749,8 @@ do_highlight(char_u *line, int forceit, int init) {
|
|||||||
|
|
||||||
xfree(HL_TABLE()[idx].sg_rgb_bg_name);
|
xfree(HL_TABLE()[idx].sg_rgb_bg_name);
|
||||||
if (STRCMP(arg, "NONE") != 0) {
|
if (STRCMP(arg, "NONE") != 0) {
|
||||||
HL_TABLE()[idx].sg_rgb_bg_name = (uint8_t *)xstrdup((char *)arg);
|
HL_TABLE()[idx].sg_rgb_bg_name = (char_u *)xstrdup((char *)arg);
|
||||||
HL_TABLE()[idx].sg_rgb_bg = name_to_color(arg);
|
HL_TABLE()[idx].sg_rgb_bg = name_to_color((const char_u *)arg);
|
||||||
} else {
|
} else {
|
||||||
HL_TABLE()[idx].sg_rgb_bg_name = NULL;
|
HL_TABLE()[idx].sg_rgb_bg_name = NULL;
|
||||||
HL_TABLE()[idx].sg_rgb_bg = -1;
|
HL_TABLE()[idx].sg_rgb_bg = -1;
|
||||||
@@ -6601,15 +6760,15 @@ do_highlight(char_u *line, int forceit, int init) {
|
|||||||
if (is_normal_group) {
|
if (is_normal_group) {
|
||||||
normal_bg = HL_TABLE()[idx].sg_rgb_bg;
|
normal_bg = HL_TABLE()[idx].sg_rgb_bg;
|
||||||
}
|
}
|
||||||
} else if (STRCMP(key, "GUISP") == 0) {
|
} else if (strcmp(key, "GUISP") == 0) {
|
||||||
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) {
|
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) {
|
||||||
if (!init)
|
if (!init)
|
||||||
HL_TABLE()[idx].sg_set |= SG_GUI;
|
HL_TABLE()[idx].sg_set |= SG_GUI;
|
||||||
|
|
||||||
xfree(HL_TABLE()[idx].sg_rgb_sp_name);
|
xfree(HL_TABLE()[idx].sg_rgb_sp_name);
|
||||||
if (STRCMP(arg, "NONE") != 0) {
|
if (strcmp(arg, "NONE") != 0) {
|
||||||
HL_TABLE()[idx].sg_rgb_sp_name = (uint8_t *)xstrdup((char *)arg);
|
HL_TABLE()[idx].sg_rgb_sp_name = (char_u *)xstrdup((char *)arg);
|
||||||
HL_TABLE()[idx].sg_rgb_sp = name_to_color(arg);
|
HL_TABLE()[idx].sg_rgb_sp = name_to_color((const char_u *)arg);
|
||||||
} else {
|
} else {
|
||||||
HL_TABLE()[idx].sg_rgb_sp_name = NULL;
|
HL_TABLE()[idx].sg_rgb_sp_name = NULL;
|
||||||
HL_TABLE()[idx].sg_rgb_sp = -1;
|
HL_TABLE()[idx].sg_rgb_sp = -1;
|
||||||
@@ -6619,31 +6778,25 @@ do_highlight(char_u *line, int forceit, int init) {
|
|||||||
if (is_normal_group) {
|
if (is_normal_group) {
|
||||||
normal_sp = HL_TABLE()[idx].sg_rgb_sp;
|
normal_sp = HL_TABLE()[idx].sg_rgb_sp;
|
||||||
}
|
}
|
||||||
} else if (STRCMP(key, "START") == 0 || STRCMP(key, "STOP") == 0) {
|
} else if (strcmp(key, "START") == 0 || strcmp(key, "STOP") == 0) {
|
||||||
// Ignored for now
|
// Ignored for now
|
||||||
} else {
|
} else {
|
||||||
EMSG2(_("E423: Illegal argument: %s"), key_start);
|
emsgf(_("E423: Illegal argument: %s"), key_start);
|
||||||
error = TRUE;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// When highlighting has been given for a group, don't link it.
|
||||||
* When highlighting has been given for a group, don't link it.
|
|
||||||
*/
|
|
||||||
if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK)) {
|
if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK)) {
|
||||||
HL_TABLE()[idx].sg_link = 0;
|
HL_TABLE()[idx].sg_link = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Continue with next argument.
|
||||||
* Continue with next argument.
|
linep = (const char *)skipwhite((const char_u *)linep);
|
||||||
*/
|
|
||||||
linep = skipwhite(linep);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// If there is an error, and it's a new entry, remove it from the table.
|
||||||
* If there is an error, and it's a new entry, remove it from the table.
|
|
||||||
*/
|
|
||||||
if (error && idx == highlight_ga.ga_len) {
|
if (error && idx == highlight_ga.ga_len) {
|
||||||
syn_unadd_group();
|
syn_unadd_group();
|
||||||
} else {
|
} else {
|
||||||
@@ -7201,7 +7354,7 @@ char_u *syn_id2name(int id)
|
|||||||
/*
|
/*
|
||||||
* Like syn_name2id(), but take a pointer + length argument.
|
* Like syn_name2id(), but take a pointer + length argument.
|
||||||
*/
|
*/
|
||||||
int syn_namen2id(char_u *linep, int len)
|
int syn_namen2id(const char_u *linep, int len)
|
||||||
{
|
{
|
||||||
char_u *name = vim_strnsave(linep, len);
|
char_u *name = vim_strnsave(linep, len);
|
||||||
int id = syn_name2id(name);
|
int id = syn_name2id(name);
|
||||||
@@ -7217,7 +7370,7 @@ int syn_namen2id(char_u *linep, int len)
|
|||||||
/// @param len length of \p pp
|
/// @param len length of \p pp
|
||||||
///
|
///
|
||||||
/// @return 0 for failure else the id of the group
|
/// @return 0 for failure else the id of the group
|
||||||
int syn_check_group(char_u *pp, int len)
|
int syn_check_group(const char_u *pp, int len)
|
||||||
{
|
{
|
||||||
char_u *name = vim_strnsave(pp, len);
|
char_u *name = vim_strnsave(pp, len);
|
||||||
int id = syn_name2id(name);
|
int id = syn_name2id(name);
|
||||||
@@ -8220,7 +8373,7 @@ color_name_table_T color_name_table[] = {
|
|||||||
///
|
///
|
||||||
/// @param[in] name string value to convert to RGB
|
/// @param[in] name string value to convert to RGB
|
||||||
/// return the hex value or -1 if could not find a correct value
|
/// return the hex value or -1 if could not find a correct value
|
||||||
RgbValue name_to_color(const uint8_t *name)
|
RgbValue name_to_color(const char_u *name)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (name[0] == '#' && isxdigit(name[1]) && isxdigit(name[2])
|
if (name[0] == '#' && isxdigit(name[1]) && isxdigit(name[2])
|
||||||
|
@@ -993,107 +993,6 @@ void viml_pexpr_free_ast(ExprAST ast)
|
|||||||
// > ># >? <= <=# <=?
|
// > ># >? <= <=# <=?
|
||||||
// < <# <? >= >=# >=?
|
// < <# <? >= >=# >=?
|
||||||
// is is# is? isnot isnot# isnot?
|
// is is# is? isnot isnot# isnot?
|
||||||
//
|
|
||||||
// Used highlighting groups and assumed linkage:
|
|
||||||
//
|
|
||||||
// NVimInternalError -> highlight as fg:red/bg:red
|
|
||||||
//
|
|
||||||
// NVimInvalid -> Error
|
|
||||||
// NVimInvalidValue -> NVimInvalid
|
|
||||||
// NVimInvalidOperator -> NVimInvalid
|
|
||||||
// NVimInvalidDelimiter -> NVimInvalid
|
|
||||||
//
|
|
||||||
// NVimOperator -> Operator
|
|
||||||
// NVimUnaryOperator -> NVimOperator
|
|
||||||
// NVimBinaryOperator -> NVimOperator
|
|
||||||
//
|
|
||||||
// NVimComparisonOperator -> NVimBinaryOperator
|
|
||||||
// NVimComparisonOperatorModifier -> NVimComparisonOperator
|
|
||||||
//
|
|
||||||
// NVimTernary -> NVimOperator
|
|
||||||
// NVimTernaryColon -> NVimTernary
|
|
||||||
//
|
|
||||||
// NVimParenthesis -> Delimiter
|
|
||||||
//
|
|
||||||
// NVimColon -> Delimiter
|
|
||||||
// NVimComma -> Delimiter
|
|
||||||
// NVimArrow -> Delimiter
|
|
||||||
//
|
|
||||||
// NVimLambda -> Delimiter
|
|
||||||
// NVimDict -> Delimiter
|
|
||||||
// NVimCurly -> Delimiter
|
|
||||||
//
|
|
||||||
// NVimList -> Delimiter
|
|
||||||
// NVimSubscript -> Delimiter
|
|
||||||
// NVimSubscriptColon -> NVimSubscript
|
|
||||||
//
|
|
||||||
// NVimIdentifier -> Identifier
|
|
||||||
// NVimIdentifierScope -> NVimIdentifier
|
|
||||||
// NVimIdentifierScopeDelimiter -> NVimIdentifier
|
|
||||||
//
|
|
||||||
// NVimIdentifierKey -> Identifier
|
|
||||||
//
|
|
||||||
// NVimUnaryPlus -> NVimUnaryOperator
|
|
||||||
// NVimBinaryPlus -> NVimBinaryOperator
|
|
||||||
// NVimConcat -> NVimBinaryOperator
|
|
||||||
// NVimConcatOrSubscript -> NVimConcat
|
|
||||||
//
|
|
||||||
// NVimRegister -> SpecialChar
|
|
||||||
// NVimNumber -> Number
|
|
||||||
// NVimNumberPrefix -> SpecialChar
|
|
||||||
// NVimFloat -> NVimNumber
|
|
||||||
//
|
|
||||||
// NVimNestingParenthesis -> NVimParenthesis
|
|
||||||
// NVimCallingParenthesis -> NVimParenthesis
|
|
||||||
//
|
|
||||||
// NVimString -> String
|
|
||||||
// NVimStringSpecial -> SpecialChar
|
|
||||||
// NVimSingleQuote -> NVimString
|
|
||||||
// NVimSingleQuotedBody -> NVimString
|
|
||||||
// NVimSingleQuotedQuote -> NVimStringSpecial
|
|
||||||
// NVimDoubleQuote -> NVimString
|
|
||||||
// NVimDoubleQuotedBody -> NVimString
|
|
||||||
// NVimDoubleQuotedEscape -> NVimStringSpecial
|
|
||||||
// NVimDoubleQuotedUnknownEscape -> NVimInvalid
|
|
||||||
//
|
|
||||||
// " Note: NVimDoubleQuotedUnknownEscape is not actually invalid
|
|
||||||
//
|
|
||||||
// NVimInvalidComma -> NVimInvalidDelimiter
|
|
||||||
// NVimInvalidSpacing -> NVimInvalid
|
|
||||||
// NVimInvalidTernary -> NVimInvalidOperator
|
|
||||||
// NVimInvalidTernaryColon -> NVimInvalidTernary
|
|
||||||
// NVimInvalidRegister -> NVimInvalidValue
|
|
||||||
// NVimInvalidClosingBracket -> NVimInvalidDelimiter
|
|
||||||
// NVimInvalidSpacing -> NVimInvalid
|
|
||||||
// NVimInvalidArrow -> NVimInvalidDelimiter
|
|
||||||
// NVimInvalidLambda -> NVimInvalidDelimiter
|
|
||||||
// NVimInvalidDict -> NVimInvalidDelimiter
|
|
||||||
// NVimInvalidCurly -> NVimInvalidDelimiter
|
|
||||||
// NVimInvalidFigureBrace -> NVimInvalidDelimiter
|
|
||||||
// NVimInvalidIdentifier -> NVimInvalidValue
|
|
||||||
// NVimInvalidIdentifierScope -> NVimInvalidValue
|
|
||||||
// NVimInvalidIdentifierScopeDelimiter -> NVimInvalidValue
|
|
||||||
// NVimInvalidComparisonOperator -> NVimInvalidOperator
|
|
||||||
// NVimInvalidComparisonOperatorModifier -> NVimInvalidComparisonOperator
|
|
||||||
// NVimInvalidNumber -> NVimInvalidValue
|
|
||||||
// NVimInvalidFloat -> NVimInvalidValue
|
|
||||||
// NVimInvalidIdentifierKey -> NVimInvalidIdentifier
|
|
||||||
// NVimInvalidList -> NVimInvalidDelimiter
|
|
||||||
// NVimInvalidSubscript -> NVimInvalidDelimiter
|
|
||||||
// NVimInvalidSubscriptColon -> NVimInvalidSubscript
|
|
||||||
// NVimInvalidString -> NVimInvalidValue
|
|
||||||
// NVimInvalidStringSpecial -> NVimInvalidString
|
|
||||||
// NVimInvalidSingleQuote -> NVimInvalidString
|
|
||||||
// NVimInvalidSingleQuotedBody -> NVimInvalidString
|
|
||||||
// NVimInvalidSingleQuotedQuote -> NVimInvalidStringSpecial
|
|
||||||
// NVimInvalidDoubleQuote -> NVimInvalidString
|
|
||||||
// NVimInvalidDoubleQuotedBody -> NVimInvalidString
|
|
||||||
// NVimInvalidDoubleQuotedEscape -> NVimInvalidStringSpecial
|
|
||||||
// NVimInvalidDoubleQuotedUnknownEscape -> NVimInvalidDoubleQuotedEscape
|
|
||||||
//
|
|
||||||
// NVimFigureBrace -> NVimInternalError
|
|
||||||
// NVimInvalidSingleQuotedUnknownEscape -> NVimInternalError
|
|
||||||
// NVimSingleQuotedUnknownEscape -> NVimInternalError
|
|
||||||
|
|
||||||
/// Allocate a new node and set some of the values
|
/// Allocate a new node and set some of the values
|
||||||
///
|
///
|
||||||
@@ -2183,12 +2082,12 @@ viml_pexpr_parse_process_token:
|
|||||||
ADD_OP_NODE(cur_node);
|
ADD_OP_NODE(cur_node);
|
||||||
if (cur_token.data.cmp.ccs != kCCStrategyUseOption) {
|
if (cur_token.data.cmp.ccs != kCCStrategyUseOption) {
|
||||||
viml_parser_highlight(pstate, cur_token.start, cur_token.len - 1,
|
viml_parser_highlight(pstate, cur_token.start, cur_token.len - 1,
|
||||||
HL(ComparisonOperator));
|
HL(Comparison));
|
||||||
viml_parser_highlight(
|
viml_parser_highlight(
|
||||||
pstate, shifted_pos(cur_token.start, cur_token.len - 1), 1,
|
pstate, shifted_pos(cur_token.start, cur_token.len - 1), 1,
|
||||||
HL(ComparisonOperatorModifier));
|
HL(ComparisonModifier));
|
||||||
} else {
|
} else {
|
||||||
HL_CUR_TOKEN(ComparisonOperator);
|
HL_CUR_TOKEN(Comparison);
|
||||||
}
|
}
|
||||||
want_node = kENodeValue;
|
want_node = kENodeValue;
|
||||||
break;
|
break;
|
||||||
@@ -2390,7 +2289,7 @@ viml_pexpr_parse_valid_colon:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kExprNodeSubscript: {
|
case kExprNodeSubscript: {
|
||||||
HL_CUR_TOKEN(Subscript);
|
HL_CUR_TOKEN(SubscriptBracket);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@@ -2418,7 +2317,7 @@ viml_pexpr_parse_bracket_closing_error:
|
|||||||
}
|
}
|
||||||
NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeSubscript);
|
NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeSubscript);
|
||||||
ADD_OP_NODE(cur_node);
|
ADD_OP_NODE(cur_node);
|
||||||
HL_CUR_TOKEN(Subscript);
|
HL_CUR_TOKEN(SubscriptBracket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2626,7 +2525,7 @@ viml_pexpr_parse_figure_brace_closing_error:
|
|||||||
cur_token.len - scope_shift,
|
cur_token.len - scope_shift,
|
||||||
(node_is_key
|
(node_is_key
|
||||||
? HL(IdentifierKey)
|
? HL(IdentifierKey)
|
||||||
: HL(Identifier)));
|
: HL(IdentifierName)));
|
||||||
} else {
|
} else {
|
||||||
if (scope == kExprVarScopeMissing) {
|
if (scope == kExprVarScopeMissing) {
|
||||||
ADD_IDENT(
|
ADD_IDENT(
|
||||||
@@ -2637,7 +2536,7 @@ viml_pexpr_parse_figure_brace_closing_error:
|
|||||||
cur_node->data.var.ident_len = cur_token.len;
|
cur_node->data.var.ident_len = cur_token.len;
|
||||||
want_node = kENodeOperator;
|
want_node = kENodeOperator;
|
||||||
} while (0),
|
} while (0),
|
||||||
Identifier);
|
IdentifierName);
|
||||||
} else {
|
} else {
|
||||||
OP_MISSING;
|
OP_MISSING;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user