neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 995e4879153d0f4ea72dff446c175754a1873425
parent 6f6286e4f90da25a7d1b6bcc96b79b0ccbaf5c26
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Thu, 30 Jun 2022 16:57:44 +0800

refactor(highlight)!: rename attributes to match Vim (#19159)

Ref: https://github.com/vim/vim/commit/84f546363068e4ddfe14a8a2a2322bb8d3a25417
Rename:
- `underlineline` to `underdouble`
- `underdot` to `underdotted`
- `underdash` to `underdashed`

`underdouble` also now takes higher precedence than `undercurl`.
Diffstat:
Mruntime/doc/api.txt | 6+++---
Mruntime/doc/builtin.txt | 6+++---
Mruntime/doc/syntax.txt | 16++++++++--------
Mruntime/doc/ui.txt | 13++++++-------
Mruntime/syntax/vim.vim | 2+-
Msrc/nvim/api/keysets.lua | 12++++++------
Msrc/nvim/api/vim.c | 6+++---
Msrc/nvim/eval/funcs.c | 34+++++++++++++++++++++-------------
Msrc/nvim/hardcopy.c | 6+++---
Msrc/nvim/hardcopy.h | 6+++---
Msrc/nvim/highlight.c | 22+++++++++++-----------
Msrc/nvim/highlight_defs.h | 22+++++++++++-----------
Msrc/nvim/highlight_group.c | 8+++++---
Msrc/nvim/tui/tui.c | 32++++++++++++++++----------------
Mtest/functional/api/highlight_spec.lua | 22+++++++++++-----------
Mtest/functional/terminal/highlight_spec.lua | 2+-
Mtest/functional/ui/screen.lua | 6+++---
17 files changed, 115 insertions(+), 106 deletions(-)

diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt @@ -1477,10 +1477,10 @@ nvim_set_hl({ns_id}, {name}, {*val}) *nvim_set_hl()* • bold: boolean • standout: boolean • underline: boolean - • underlineline: boolean • undercurl: boolean - • underdot: boolean - • underdash: boolean + • underdouble: boolean + • underdotted: boolean + • underdashed: boolean • strikethrough: boolean • italic: boolean • reverse: boolean diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt @@ -8026,10 +8026,10 @@ synIDattr({synID}, {what} [, {mode}]) *synIDattr()* "inverse" "1" if inverse (= reverse) "standout" "1" if standout "underline" "1" if underlined - "underlineline" "1" if double underlined "undercurl" "1" if undercurled - "underdot" "1" if dotted underlined - "underdash" "1" if dashed underlined + "underdouble" "1" if double underlined + "underdotted" "1" if dotted underlined + "underdashed" "1" if dashed underlined "strikethrough" "1" if struckthrough Example (echoes the color of the syntax item under the diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt @@ -4895,19 +4895,19 @@ the same syntax file on all UIs. 1. TUI highlight arguments - *bold* *underline* *underlineline* - *undercurl* *underdot* *underdash* - *inverse* *italic* *standout* - *nocombine* *strikethrough* + *bold* *underline* *undercurl* + *underdouble* *underdotted* + *underdashed* *inverse* *italic* + *standout* *nocombine* *strikethrough* cterm={attr-list} *attr-list* *highlight-cterm* *E418* attr-list is a comma-separated list (without spaces) of the following items (in any order): bold underline - underlineline double underline undercurl curly underline - underdot dotted underline - underdash dashed underline + underdouble double underline + underdotted dotted underline + underdashed dashed underline strikethrough reverse inverse same as reverse @@ -4918,7 +4918,7 @@ cterm={attr-list} *attr-list* *highlight-cterm* *E418* Note that "bold" can be used here and by using a bold font. They have the same effect. - "underlineline", "undercurl", "underdot", and "underdash" fall back + "undercurl", "underdouble", "underdotted", and "underdashed" fall back to "underline" in a terminal that does not support them. The color is set using |highlight-guisp|. diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt @@ -314,11 +314,10 @@ numerical highlight ids to the actual attributes. `bold`: bold text. `strikethrough`: struckthrough text. `underline`: underlined text. The line has `special` color. - `underlineline`: double underlined text. The lines have `special` - color. `undercurl`: undercurled text. The curl has `special` color. - `underdot`: underdotted text. The dots have `special` color. - `underdash`: underdashed text. The dashes have `special` color. + `underdouble`: double underlined text. The lines have `special` color. + `underdotted`: underdotted text. The dots have `special` color. + `underdashed`: underdashed text. The dashes have `special` color. `blend`: Blend level (0-100). Could be used by UIs to support blending floating windows to the background or to signal a transparent cursor. @@ -477,10 +476,10 @@ is not active. New UIs should implement |ui-linegrid| instead. `bold`: bold text. `strikethrough`: struckthrough text. `underline`: underlined text. The line has `special` color. - `underlineline`: double underlined text. The lines have `special` color. `undercurl`: undercurled text. The curl has `special` color. - `underdot`: underdotted text. The dots have `special` color. - `underdash`: underdashed text. The dashes have `special` color. + `underdouble`: double underlined text. The lines have `special` color. + `underdotted`: underdotted text. The dots have `special` color. + `underdashed`: underdashed text. The dashes have `special` color. ["put", text] The (utf-8 encoded) string `text` is put at the cursor position diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim @@ -572,7 +572,7 @@ syn match vimHiBang contained "!" skipwhite nextgroup=@vimHighlightCluster syn match vimHiGroup contained "\i\+" syn case ignore -syn keyword vimHiAttrib contained none bold inverse italic nocombine reverse standout strikethrough underline underlineline undercurl underdot underdash +syn keyword vimHiAttrib contained none bold inverse italic nocombine reverse standout strikethrough underline undercurl underdouble underdotted underdashed syn keyword vimFgBgAttrib contained none bg background fg foreground syn case match syn match vimHiAttribList contained "\i\+" contains=vimHiAttrib diff --git a/src/nvim/api/keysets.lua b/src/nvim/api/keysets.lua @@ -95,10 +95,10 @@ return { "standout"; "strikethrough"; "underline"; - "underlineline"; "undercurl"; - "underdot"; - "underdash"; + "underdouble"; + "underdotted"; + "underdashed"; "italic"; "reverse"; "nocombine"; @@ -120,10 +120,10 @@ return { "standout"; "strikethrough"; "underline"; - "underlineline"; "undercurl"; - "underdot"; - "underdash"; + "underdouble"; + "underdotted"; + "underdashed"; "italic"; "reverse"; "nocombine"; diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c @@ -149,10 +149,10 @@ Dictionary nvim__get_hl_defs(Integer ns_id, Error *err) /// - bold: boolean /// - standout: boolean /// - underline: boolean -/// - underlineline: boolean /// - undercurl: boolean -/// - underdot: boolean -/// - underdash: boolean +/// - underdouble: boolean +/// - underdotted: boolean +/// - underdashed: boolean /// - strikethrough: boolean /// - italic: boolean /// - reverse: boolean diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c @@ -10303,22 +10303,30 @@ static void f_synIDattr(typval_T *argvars, typval_T *rettv, FunPtr fptr) p = highlight_has_attr(id, HL_STANDOUT, modec); } break; - case 'u': { - const size_t len = STRLEN(what); - if (len <= 5 || (TOLOWER_ASC(what[5]) == 'l' && len <= 9)) { // underline - p = highlight_has_attr(id, HL_UNDERLINE, modec); - } else if (TOLOWER_ASC(what[5]) == 'c') { // undercurl - p = highlight_has_attr(id, HL_UNDERCURL, modec); - } else if (len > 9 && TOLOWER_ASC(what[9]) == 'l') { // underlineline - p = highlight_has_attr(id, HL_UNDERLINELINE, modec); - } else if (len > 6 && TOLOWER_ASC(what[6]) == 'o') { // underdot - p = highlight_has_attr(id, HL_UNDERDOT, modec); - } else { // underdash - p = highlight_has_attr(id, HL_UNDERDASH, modec); + case 'u': + if (STRLEN(what) >= 9) { + if (TOLOWER_ASC(what[5]) == 'l') { + // underline + p = highlight_has_attr(id, HL_UNDERLINE, modec); + } else if (TOLOWER_ASC(what[5]) != 'd') { + // undercurl + p = highlight_has_attr(id, HL_UNDERCURL, modec); + } else if (TOLOWER_ASC(what[6]) != 'o') { + // underdashed + p = highlight_has_attr(id, HL_UNDERDASHED, modec); + } else if (TOLOWER_ASC(what[7]) == 'u') { + // underdouble + p = highlight_has_attr(id, HL_UNDERDOUBLE, modec); + } else { + // underdotted + p = highlight_has_attr(id, HL_UNDERDOTTED, modec); + } + } else { + // ul + p = highlight_color(id, what, modec); } break; } - } rettv->v_type = VAR_STRING; rettv->vval.v_string = (char *)(p == NULL ? p : xstrdup(p)); diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c @@ -419,10 +419,10 @@ static void prt_get_attr(int hl_id, prt_text_attr_T *pattr, int modec) pattr->bold = (highlight_has_attr(hl_id, HL_BOLD, modec) != NULL); pattr->italic = (highlight_has_attr(hl_id, HL_ITALIC, modec) != NULL); pattr->underline = (highlight_has_attr(hl_id, HL_UNDERLINE, modec) != NULL); - pattr->underlineline = (highlight_has_attr(hl_id, HL_UNDERLINELINE, modec) != NULL); pattr->undercurl = (highlight_has_attr(hl_id, HL_UNDERCURL, modec) != NULL); - pattr->underdot = (highlight_has_attr(hl_id, HL_UNDERDOT, modec) != NULL); - pattr->underdash = (highlight_has_attr(hl_id, HL_UNDERDASH, modec) != NULL); + pattr->underdouble = (highlight_has_attr(hl_id, HL_UNDERDOUBLE, modec) != NULL); + pattr->underdotted = (highlight_has_attr(hl_id, HL_UNDERDOTTED, modec) != NULL); + pattr->underdashed = (highlight_has_attr(hl_id, HL_UNDERDASHED, modec) != NULL); uint32_t fg_color = prt_get_color(hl_id, modec); diff --git a/src/nvim/hardcopy.h b/src/nvim/hardcopy.h @@ -18,9 +18,9 @@ typedef struct { TriState italic; TriState underline; int undercurl; - int underlineline; - int underdot; - int underdash; + int underdouble; + int underdotted; + int underdashed; } prt_text_attr_T; /* diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c @@ -743,20 +743,20 @@ Dictionary hlattrs2dict(HlAttrs ae, bool use_rgb) PUT(hl, "underline", BOOLEAN_OBJ(true)); } - if (mask & HL_UNDERLINELINE) { - PUT(hl, "underlineline", BOOLEAN_OBJ(true)); - } - if (mask & HL_UNDERCURL) { PUT(hl, "undercurl", BOOLEAN_OBJ(true)); } - if (mask & HL_UNDERDOT) { - PUT(hl, "underdot", BOOLEAN_OBJ(true)); + if (mask & HL_UNDERDOUBLE) { + PUT(hl, "underdouble", BOOLEAN_OBJ(true)); + } + + if (mask & HL_UNDERDOTTED) { + PUT(hl, "underdotted", BOOLEAN_OBJ(true)); } - if (mask & HL_UNDERDASH) { - PUT(hl, "underdash", BOOLEAN_OBJ(true)); + if (mask & HL_UNDERDASHED) { + PUT(hl, "underdashed", BOOLEAN_OBJ(true)); } if (mask & HL_ITALIC) { @@ -825,10 +825,10 @@ HlAttrs dict2hlattrs(Dict(highlight) *dict, bool use_rgb, int *link_id, Error *e CHECK_FLAG(dict, mask, bold, , HL_BOLD); CHECK_FLAG(dict, mask, standout, , HL_STANDOUT); CHECK_FLAG(dict, mask, underline, , HL_UNDERLINE); - CHECK_FLAG(dict, mask, underlineline, , HL_UNDERLINELINE); CHECK_FLAG(dict, mask, undercurl, , HL_UNDERCURL); - CHECK_FLAG(dict, mask, underdot, , HL_UNDERDOT); - CHECK_FLAG(dict, mask, underdash, , HL_UNDERDASH); + CHECK_FLAG(dict, mask, underdouble, , HL_UNDERDOUBLE); + CHECK_FLAG(dict, mask, underdotted, , HL_UNDERDOTTED); + CHECK_FLAG(dict, mask, underdashed, , HL_UNDERDASHED); CHECK_FLAG(dict, mask, italic, , HL_ITALIC); CHECK_FLAG(dict, mask, reverse, , HL_INVERSE); CHECK_FLAG(dict, mask, strikethrough, , HL_STRIKETHROUGH); diff --git a/src/nvim/highlight_defs.h b/src/nvim/highlight_defs.h @@ -17,17 +17,17 @@ typedef enum { HL_ITALIC = 0x04, HL_UNDERLINE = 0x08, HL_UNDERCURL = 0x10, - HL_STANDOUT = 0x20, - HL_STRIKETHROUGH = 0x40, - HL_NOCOMBINE = 0x80, - HL_BG_INDEXED = 0x0100, - HL_FG_INDEXED = 0x0200, - HL_DEFAULT = 0x0400, - HL_GLOBAL = 0x0800, - HL_UNDERLINELINE = 0x1000, - HL_UNDERDOT = 0x2000, - HL_UNDERDASH = 0x4000, - HL_ANY_UNDERLINE = HL_UNDERLINE | HL_UNDERLINELINE | HL_UNDERCURL | HL_UNDERDOT | HL_UNDERDASH, + HL_UNDERDOUBLE = 0x20, + HL_UNDERDOTTED = 0x40, + HL_UNDERDASHED = 0x80, + HL_STANDOUT = 0x0100, + HL_NOCOMBINE = 0x0200, + HL_STRIKETHROUGH = 0x0400, + HL_BG_INDEXED = 0x0800, + HL_FG_INDEXED = 0x1000, + HL_DEFAULT = 0x2000, + HL_GLOBAL = 0x4000, + HL_ANY_UNDERLINE = HL_UNDERLINE | HL_UNDERDOUBLE | HL_UNDERCURL | HL_UNDERDOTTED | HL_UNDERDASHED, } HlAttrFlags; /// Stores a complete highlighting entry, including colors and attributes diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c @@ -38,10 +38,12 @@ Map(cstr_t, int) highlight_unames = MAP_INIT; /// The "term", "cterm" and "gui" arguments can be any combination of the /// following names, separated by commas (but no spaces!). static char *(hl_name_table[]) = -{ "bold", "standout", "underline", "underlineline", "undercurl", "underdot", - "underdash", "italic", "reverse", "inverse", "strikethrough", "nocombine", "NONE" }; +{ "bold", "standout", "underline", + "undercurl", "underdouble", "underdotted", "underdashed", + "italic", "reverse", "inverse", "strikethrough", "nocombine", "NONE" }; static int hl_attr_table[] = -{ HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERLINELINE, HL_UNDERCURL, HL_UNDERDOT, HL_UNDERDASH, +{ HL_BOLD, HL_STANDOUT, HL_UNDERLINE, + HL_UNDERCURL, HL_UNDERDOUBLE, HL_UNDERDOTTED, HL_UNDERDASHED, HL_ITALIC, HL_INVERSE, HL_INVERSE, HL_STRIKETHROUGH, HL_NOCOMBINE, 0 }; /// Structure that stores information about a highlight group. diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c @@ -589,26 +589,26 @@ static void update_attrs(UI *ui, int attr_id) bool strikethrough = attr & HL_STRIKETHROUGH; bool underline; - bool underlineline; bool undercurl; - bool underdot; - bool underdash; + bool underdouble; + bool underdotted; + bool underdashed; if (data->unibi_ext.set_underline_style != -1) { underline = attr & HL_UNDERLINE; - underlineline = attr & HL_UNDERLINELINE; undercurl = attr & HL_UNDERCURL; - underdash = attr & HL_UNDERDASH; - underdot = attr & HL_UNDERDOT; + underdouble = attr & HL_UNDERDOUBLE; + underdashed = attr & HL_UNDERDASHED; + underdotted = attr & HL_UNDERDOTTED; } else { underline = attr & HL_ANY_UNDERLINE; - underlineline = false; undercurl = false; - underdot = false; - underdash = false; + underdouble = false; + underdotted = false; + underdashed = false; } bool has_any_underline = undercurl || underline - || underdot || underdash || underlineline; + || underdouble || underdotted || underdashed; if (unibi_get_str(data->ut, unibi_set_attributes)) { if (bold || reverse || underline || standout) { @@ -648,19 +648,19 @@ static void update_attrs(UI *ui, int attr_id) if (strikethrough && data->unibi_ext.enter_strikethrough_mode != -1) { unibi_out_ext(ui, data->unibi_ext.enter_strikethrough_mode); } - if (underlineline && data->unibi_ext.set_underline_style != -1) { - UNIBI_SET_NUM_VAR(data->params[0], 2); - unibi_out_ext(ui, data->unibi_ext.set_underline_style); - } if (undercurl && data->unibi_ext.set_underline_style != -1) { UNIBI_SET_NUM_VAR(data->params[0], 3); unibi_out_ext(ui, data->unibi_ext.set_underline_style); } - if (underdot && data->unibi_ext.set_underline_style != -1) { + if (underdouble && data->unibi_ext.set_underline_style != -1) { + UNIBI_SET_NUM_VAR(data->params[0], 2); + unibi_out_ext(ui, data->unibi_ext.set_underline_style); + } + if (underdotted && data->unibi_ext.set_underline_style != -1) { UNIBI_SET_NUM_VAR(data->params[0], 4); unibi_out_ext(ui, data->unibi_ext.set_underline_style); } - if (underdash && data->unibi_ext.set_underline_style != -1) { + if (underdashed && data->unibi_ext.set_underline_style != -1) { UNIBI_SET_NUM_VAR(data->params[0], 5); unibi_out_ext(ui, data->unibi_ext.set_underline_style); } diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua @@ -29,10 +29,10 @@ describe('API: highlight',function() italic = true, reverse = true, underline = true, - underlineline = true, undercurl = true, - underdot = true, - underdash = true, + underdouble = true, + underdotted = true, + underdashed = true, strikethrough = true, } @@ -55,7 +55,7 @@ describe('API: highlight',function() eq('Invalid highlight id: 30000', string.match(emsg, 'Invalid.*')) -- Test all highlight properties. - command('hi NewHighlight gui=underline,bold,underlineline,undercurl,underdot,underdash,italic,reverse,strikethrough') + command('hi NewHighlight gui=underline,bold,undercurl,underdouble,underdotted,underdashed,italic,reverse,strikethrough') eq(expected_rgb2, nvim("get_hl_by_id", hl_id, true)) -- Test nil argument. @@ -205,9 +205,9 @@ describe("API: set highlight", function() reverse = true, undercurl = true, underline = true, - underdash = true, - underdot = true, - underlineline = true, + underdashed = true, + underdotted = true, + underdouble = true, strikethrough = true, cterm = { italic = true, @@ -224,9 +224,9 @@ describe("API: set highlight", function() reverse = true, undercurl = true, underline = true, - underdash = true, - underdot = true, - underlineline = true, + underdashed = true, + underdotted = true, + underdouble = true, strikethrough = true, } local highlight3_result_cterm = { @@ -290,7 +290,7 @@ describe("API: set highlight", function() exec_capture('highlight Test_hl')) meths.set_hl(0, 'Test_hl2', highlight3_config) - eq('Test_hl2 xxx cterm=undercurl,italic,reverse,strikethrough ctermfg=8 ctermbg=15 gui=bold,underline,underlineline,undercurl,underdot,underdash,italic,reverse,strikethrough guifg=#ff0000 guibg=#0032aa', + eq('Test_hl2 xxx cterm=undercurl,italic,reverse,strikethrough ctermfg=8 ctermbg=15 gui=bold,underline,undercurl,underdouble,underdotted,underdashed,italic,reverse,strikethrough guifg=#ff0000 guibg=#0032aa', exec_capture('highlight Test_hl2')) -- Colors are stored with the name they are defined, but diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua @@ -306,7 +306,7 @@ describe('synIDattr()', function() it('returns "1" if group has given highlight attribute', function() local hl_attrs = { - 'underline', 'underlineline', 'undercurl', 'underdot', 'underdash', 'strikethrough' + 'underline', 'undercurl', 'underdouble', 'underdotted', 'underdashed', 'strikethrough' } for _,hl_attr in ipairs(hl_attrs) do local context = 'using ' .. hl_attr .. ' attr' diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua @@ -1579,9 +1579,9 @@ end function Screen:_equal_attrs(a, b) return a.bold == b.bold and a.standout == b.standout and - a.underline == b.underline and a.underlineline == b.underlineline and - a.undercurl == b.undercurl and a.underdot == b.underdot and - a.underdash == b.underdash and a.italic == b.italic and + a.underline == b.underline and a.undercurl == b.undercurl and + a.underdouble == b.underdouble and a.underdotted == b.underdotted and + a.underdashed == b.underdashed and a.italic == b.italic and a.reverse == b.reverse and a.foreground == b.foreground and a.background == b.background and a.special == b.special and a.blend == b.blend and a.strikethrough == b.strikethrough and