diff options
-rw-r--r-- | runtime/doc/options.txt | 38 | ||||
-rw-r--r-- | runtime/doc/syntax.txt | 24 | ||||
-rw-r--r-- | runtime/doc/vim_diff.txt | 1 | ||||
-rw-r--r-- | src/nvim/globals.h | 3 | ||||
-rw-r--r-- | src/nvim/option.c | 3 | ||||
-rw-r--r-- | src/nvim/screen.c | 8 | ||||
-rw-r--r-- | src/nvim/syntax.c | 1 | ||||
-rw-r--r-- | test/functional/ui/cursor_spec.lua | 40 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 105 |
9 files changed, 92 insertions, 131 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index eedb7ce34d..bd9bc5820b 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3171,29 +3171,17 @@ A jump table for the options with a short description can be found at |Q_op|. Think twice when using ":q!" or ":qa!". *'highlight'* *'hl'* -'highlight' 'hl' string (default (as a single string): - "8:SpecialKey,~:EndOfBuffer,z:TermCursor, - Z:TermCursorNC,@:NonText,d:Directory, - e:ErrorMsg,i:IncSearch,l:Search, - m:MoreMsg,M:ModeMsg,n:LineNr, - N:CursorLineNr,r:Question,s:StatusLine, - S:StatusLineNC,c:VertSplit,t:Title, - v:Visual,w:WarningMsg,W:WildMenu, - f:Folded,F:FoldColumn,A:DiffAdd, - C:DiffChange,D:DiffDelete,T:DiffText, - >:SignColumn,B:SpellBad,P:SpellCap, - R:SpellRare,L:SpellLocal,-:Conceal, - +:Pmenu,=:PmenuSel,x:PmenuSbar, - X:PmenuThumb") +'highlight' 'hl' string (default: string of "c:group,..." pairs) global This option can be used to set highlighting mode for various occasions. It is a comma separated list of character pairs. The first character in a pair gives the occasion, the second the mode to use for that occasion. The occasions are: |hl-SpecialKey| 8 Meta and special keys listed with ":map" - |hl-EndOfBuffer| ~ lines after the last line in the buffer + |hl-Whitespace| 0 + |hl-EndOfBuffer| ~ lines after the last line in the buffer |hl-TermCursor| z Cursor in a focused terminal - |hl-TermCursorNC| Z Cursor in an unfocused terminal + |hl-TermCursorNC| Z Cursor in an unfocused terminal |hl-NonText| @ '@' at the end of the window and characters from 'showbreak' |hl-Directory| d directories in CTRL-D listing and other special @@ -3205,11 +3193,11 @@ A jump table for the options with a short description can be found at |Q_op|. |hl-ModeMsg| M Mode (e.g., "-- INSERT --") |hl-LineNr| n line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set. - |hl-CursorLineNr| N like n for when 'cursorline' or 'relativenumber' is + |hl-CursorLineNr| N like n for when 'cursorline' or 'relativenumber' is set. |hl-Question| r |hit-enter| prompt and yes/no questions |hl-StatusLine| s status line of current window |status-line| - |hl-StatusLineNC| S status lines of not-current windows + |hl-StatusLineNC| S status lines of not-current windows |hl-Title| t Titles for output from ":set all", ":autocmd" etc. |hl-VertSplit| c column used to separate vertically split windows |hl-Visual| v Visual mode @@ -3233,6 +3221,15 @@ A jump table for the options with a short description can be found at |Q_op|. |hl-PmenuSbar| x popup menu scrollbar |hl-PmenuThumb| X popup menu scrollbar thumb + |hl-TabLine| * + |hl-TabLineFill| _ + |hl-TabLineSel| # + + |hl-ColorColumn| o + |hl-CursorColumn| ! + |hl-CursorLine| . + |hl-QuickFixLine| q + The display modes are: r reverse (termcap entry "mr" and "me") i italic (termcap entry "ZH" and "ZR") @@ -3917,9 +3914,8 @@ A jump table for the options with a short description can be found at |Q_op|. :set lcs=tab:>-,trail:- :set lcs=tab:>-,eol:<,nbsp:% :set lcs=extends:>,precedes:< -< The "NonText" highlighting will be used for "eol", "extends" and - "precedes". "SpecialKey" for "nbsp", "space", "tab" and "trail". - |hl-NonText| |hl-SpecialKey| +< |hl-NonText| highlighting will be used for "eol", "extends" and + "precedes". |hl-Whitespace| for "nbsp", "space", "tab" and "trail". *'lpl'* *'nolpl'* *'loadplugins'* *'noloadplugins'* 'loadplugins' 'lpl' boolean (default on) diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index b0b4cabd65..f7c2c0e120 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -4899,32 +4899,28 @@ PmenuThumb Popup menu: Thumb of the scrollbar. *hl-Question* Question |hit-enter| prompt and yes/no questions *hl-QuickFixLine* -QuickFixLine The selected |quickfix| item in the quickfix window. - |hl-CursorLine| is combined with this when the cursor is on - the currently selected quickfix item. +QuickFixLine Current |quickfix| item in the quickfix window. Combined with + |hl-CursorLine| when the cursor is there. *hl-Search* Search Last search pattern highlighting (see 'hlsearch'). - Also used for highlighting the current line in the quickfix - window and similar items that need to stand out. + Also used for similar items that need to stand out. *hl-SpecialKey* -SpecialKey Meta and special keys listed with ":map", also for text used - to show unprintable characters in the text, 'listchars'. - Generally: text that is displayed differently from what it - really is. +SpecialKey Unprintable characters: text displayed differently from what + it really is. But not 'listchars' whitespace. |hl-Whitespace| *hl-SpellBad* SpellBad Word that is not recognized by the spellchecker. |spell| - This will be combined with the highlighting used otherwise. + Combined with the highlighting used otherwise. *hl-SpellCap* SpellCap Word that should start with a capital. |spell| - This will be combined with the highlighting used otherwise. + Combined with the highlighting used otherwise. *hl-SpellLocal* SpellLocal Word that is recognized by the spellchecker as one that is used in another region. |spell| - This will be combined with the highlighting used otherwise. + Combined with the highlighting used otherwise. *hl-SpellRare* SpellRare Word that is recognized by the spellchecker as one that is hardly ever used. |spell| - This will be combined with the highlighting used otherwise. + Combined with the highlighting used otherwise. *hl-StatusLine* StatusLine status line of current window *hl-StatusLineNC* @@ -4943,6 +4939,8 @@ Title titles for output from ":set all", ":autocmd" etc. Visual Visual mode selection *hl-WarningMsg* WarningMsg warning messages + *hl-Whitespace* +Whitespace "nbsp", "space", "tab" and "trail" in 'listchars' *hl-WildMenu* WildMenu current match in 'wildmenu' completion diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index bd43028806..c84cea2b55 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -147,6 +147,7 @@ Highlight groups: |hl-Substitute| |hl-TermCursor| |hl-TermCursorNC| + |hl-Whitespace| highlights 'listchars' whitespace ============================================================================== 4. Changed features *nvim-features-changed* diff --git a/src/nvim/globals.h b/src/nvim/globals.h index c15287aa38..3c705d88a5 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -464,6 +464,7 @@ typedef enum { , HLF_CUL // 'cursurline' , HLF_MC // 'colorcolumn' , HLF_QFL // selected quickfix line + , HLF_0 // Whitespace , HLF_COUNT // MUST be the last one } hlf_T; @@ -472,7 +473,7 @@ typedef enum { #define HL_FLAGS { '8', '~', 'z', 'Z', '@', 'd', 'e', 'i', 'l', 'm', 'M', 'n', \ 'N', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', 'f', 'F', \ 'A', 'C', 'D', 'T', '-', '>', 'B', 'P', 'R', 'L', '+', '=', \ - 'x', 'X', '*', '#', '_', '!', '.', 'o', 'q' } + 'x', 'X', '*', '#', '_', '!', '.', 'o', 'q', '0' } EXTERN int highlight_attr[HLF_COUNT]; /* Highl. attr for each context. */ EXTERN int highlight_user[9]; /* User[1-9] attributes */ diff --git a/src/nvim/option.c b/src/nvim/option.c index b3b4dc1e0a..695d0edebf 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -245,7 +245,8 @@ typedef struct vimoption { "A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal," \ "B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel," \ "x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill," \ - "!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine" + "!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine," \ + "0:Whitespace" /* * options[] is initialized here. diff --git a/src/nvim/screen.c b/src/nvim/screen.c index cf460adb82..d9a21aa81f 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -3409,7 +3409,7 @@ win_line ( || (c == ' ' && lcs_space && ptr - line <= trailcol))) { c = (c == ' ') ? lcs_space : lcs_nbsp; n_attr = 1; - extra_attr = hl_attr(HLF_8); + extra_attr = hl_attr(HLF_0); saved_attr2 = char_attr; // save current attr mb_c = c; if (enc_utf8 && (*mb_char2len)(c) > 1) { @@ -3424,7 +3424,7 @@ win_line ( if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ') { c = lcs_trail; n_attr = 1; - extra_attr = hl_attr(HLF_8); + extra_attr = hl_attr(HLF_0); saved_attr2 = char_attr; // save current attr mb_c = c; if (enc_utf8 && (*mb_char2len)(c) > 1) { @@ -3525,8 +3525,8 @@ win_line ( c_extra = lcs_tab2; } n_attr = tab_len + 1; - extra_attr = hl_attr(HLF_8); - saved_attr2 = char_attr; /* save current attr */ + extra_attr = hl_attr(HLF_0); + saved_attr2 = char_attr; // save current attr mb_c = c; if (enc_utf8 && (*mb_char2len)(c) > 1) { mb_utf8 = TRUE; diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index acda25e738..e36b00d770 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5916,6 +5916,7 @@ static char *highlight_init_both[] = "default link EndOfBuffer NonText", "default link QuickFixLine Search", "default link Substitute Search", + "default link Whitespace NonText", NULL }; diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 56f02e4e7f..1e3a9fcb60 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -30,8 +30,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 25, cursor_shape = 'vertical', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'ci' }, cmdline_normal = { @@ -40,8 +40,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 0, cursor_shape = 'block', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'c' }, cmdline_replace = { @@ -50,8 +50,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 20, cursor_shape = 'horizontal', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'cr' }, insert = { @@ -60,8 +60,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 25, cursor_shape = 'vertical', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'i' }, more = { @@ -76,8 +76,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 0, cursor_shape = 'block', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'n' }, operator = { @@ -86,8 +86,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 50, cursor_shape = 'horizontal', - hl_id = 45, - id_lm = 45, + hl_id = 46, + id_lm = 46, mouse_shape = 0, short_name = 'o' }, replace = { @@ -96,8 +96,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 20, cursor_shape = 'horizontal', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'r' }, showmatch = { @@ -106,8 +106,8 @@ describe('ui/cursor', function() blinkwait = 175, cell_percentage = 0, cursor_shape = 'block', - hl_id = 45, - id_lm = 45, + hl_id = 46, + id_lm = 46, short_name = 'sm' }, statusline_drag = { mouse_shape = 0, @@ -121,8 +121,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 0, cursor_shape = 'block', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'v' }, visual_select = { @@ -131,8 +131,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 35, cursor_shape = 'vertical', - hl_id = 45, - id_lm = 45, + hl_id = 46, + id_lm = 46, mouse_shape = 0, short_name = 've' }, vsep_drag = { diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 7a1b8c91e7..05cf3231ea 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -200,58 +200,31 @@ describe('Default highlight groups', function() it('insert mode text', function() feed('i') + screen:try_resize(53, 4) screen:expect([[ ^ | {0:~ }| {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| {1:-- INSERT --} | ]], {[0] = {bold=true, foreground=Screen.colors.Blue}, [1] = {bold = true}}) end) it('end of file markers', function() + screen:try_resize(53, 4) screen:expect([[ ^ | {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | ]], {[1] = {bold = true, foreground = Screen.colors.Blue}}) end) it('"wait return" text', function() + screen:try_resize(53, 4) feed(':ls<cr>') screen:expect([[ {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| :ls | 1 %a "[No Name]" line 1 | {1:Press ENTER or type command to continue}^ | @@ -259,23 +232,15 @@ describe('Default highlight groups', function() [1] = {bold = true, foreground = Screen.colors.SeaGreen}}) feed('<cr>') -- skip the "Press ENTER..." state or tests will hang end) + it('can be cleared and linked to other highlight groups', function() + screen:try_resize(53, 4) execute('highlight clear ModeMsg') feed('i') screen:expect([[ ^ | {0:~ }| {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| -- INSERT -- | ]], {[0] = {bold=true, foreground=Screen.colors.Blue}, [1] = {bold=true}}) @@ -287,21 +252,13 @@ describe('Default highlight groups', function() ^ | {0:~ }| {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| {1:-- INSERT --} | ]], {[0] = {bold=true, foreground=Screen.colors.Blue}, [1] = {foreground = Screen.colors.Red, background = Screen.colors.Green}}) end) + it('can be cleared by assigning NONE', function() + screen:try_resize(53, 4) execute('syn keyword TmpKeyword neovim') execute('hi link TmpKeyword ErrorMsg') insert('neovim') @@ -309,16 +266,6 @@ describe('Default highlight groups', function() {1:neovi^m} | {0:~ }| {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| | ]], { [0] = {bold=true, foreground=Screen.colors.Blue}, @@ -330,18 +277,34 @@ describe('Default highlight groups', function() neovi^m | {0:~ }| {0:~ }| + | + ]], {[0] = {bold=true, foreground=Screen.colors.Blue}}) + end) + + it('Whitespace highlight', function() + screen:try_resize(53, 4) + execute('highlight NonText gui=NONE guifg=#FF0000') + execute('set listchars=space:.,tab:>-,trail:*,eol:¬ list') + insert(' ne \t o\tv im ') + screen:expect([[ + ne{0:.>----.}o{0:>-----}v{0:..}im{0:*^*¬} | {0:~ }| {0:~ }| + | + ]], { + [0] = {foreground=Screen.colors.Red}, + [1] = {foreground=Screen.colors.Blue}, + }) + execute('highlight Whitespace gui=NONE guifg=#0000FF') + screen:expect([[ + ne{1:.>----.}o{1:>-----}v{1:..}im{1:*^*}{0:¬} | {0:~ }| {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - | - ]], {[0] = {bold=true, foreground=Screen.colors.Blue}}) + :highlight Whitespace gui=NONE guifg=#0000FF | + ]], { + [0] = {foreground=Screen.colors.Red}, + [1] = {foreground=Screen.colors.Blue}, + }) end) end) @@ -510,7 +473,7 @@ describe("'listchars' highlight", function() }, }) execute('highlight clear ModeMsg') - execute('highlight SpecialKey guifg=#FF0000') + execute('highlight Whitespace guifg=#FF0000') execute('set cursorline') execute('set tabstop=8') execute('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list') @@ -606,7 +569,7 @@ describe("'listchars' highlight", function() }, }) execute('highlight clear ModeMsg') - execute('highlight SpecialKey guifg=#FF0000') + execute('highlight Whitespace guifg=#FF0000') execute('set cursorline') execute('set tabstop=8') execute('set nowrap') @@ -653,7 +616,7 @@ describe("'listchars' highlight", function() [3] = {foreground=Screen.colors.Green1}, }) execute('highlight clear ModeMsg') - execute('highlight SpecialKey guifg=#FF0000') + execute('highlight Whitespace guifg=#FF0000') execute('highlight Error guifg=#00FF00') execute('set nowrap') feed('ia \t bc \t <esc>') |