highlight: Added QuickFixLine highlight group

- Links to Search by default

screen.c: Combine CursorLine with QuickFixLine

- HLF_QFL takes priority over HLF_CUL

docs: Updated to mention QuickFixLine
runtime: Added QuickFixLine to nvimHLGroup
tests: QuickFixLine highlight
This commit is contained in:
Tommy Allen 2016-08-03 16:56:05 -04:00
parent dfb6a5133b
commit 605e74327a
8 changed files with 213 additions and 6 deletions

View File

@ -4883,6 +4883,10 @@ PmenuSbar Popup menu: scrollbar.
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.
*hl-Search*
Search Last search pattern highlighting (see 'hlsearch').
Also used for highlighting the current line in the quickfix

View File

@ -53,7 +53,7 @@ syn keyword vimGroup contained Comment Constant String Character Number Boolean
syn keyword vimHLGroup contained ColorColumn Cursor CursorColumn CursorIM CursorLine CursorLineNr DiffAdd DiffChange DiffDelete DiffText Directory ErrorMsg FoldColumn Folded IncSearch LineNr MatchParen Menu ModeMsg MoreMsg NonText Normal Pmenu PmenuSbar PmenuSel PmenuThumb Question Scrollbar Search SignColumn SpecialKey SpellBad SpellCap SpellLocal SpellRare StatusLine StatusLineNC TabLine TabLineFill TabLineSel Title Tooltip VertSplit Visual WarningMsg WildMenu
syn match vimHLGroup contained "Conceal"
syn keyword vimOnlyHLGroup contained VisualNOS
syn keyword nvimHLGroup contained EndOfBuffer TermCursor TermCursorNC
syn keyword nvimHLGroup contained EndOfBuffer TermCursor TermCursorNC QuickFixLine
"}}}2
syn case match
" Special Vim Highlighting (not automatic) {{{1

View File

@ -486,6 +486,7 @@ typedef enum {
, HLF_CUC /* 'cursurcolumn' */
, HLF_CUL /* 'cursurline' */
, HLF_MC /* 'colorcolumn' */
, HLF_QFL // selected quickfix line
, HLF_COUNT /* MUST be the last one */
} hlf_T;
@ -494,7 +495,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'}
'x', 'X', '*', '#', '_', '!', '.', 'o', 'q'}
EXTERN int highlight_attr[HLF_COUNT]; /* Highl. attr for each context. */
EXTERN int highlight_user[9]; /* User[1-9] attributes */

View File

@ -246,7 +246,7 @@ 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"
"!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine"
/*
* options[] is initialized here.

View File

@ -1764,7 +1764,7 @@ void qf_list(exarg_T *eap)
vim_snprintf((char *)IObuff, IOSIZE, "%2d %s",
i, (char *)fname);
msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index
? hl_attr(HLF_L) : hl_attr(HLF_D));
? hl_attr(HLF_QFL) : hl_attr(HLF_D));
if (qfp->qf_lnum == 0)
IObuff[0] = NUL;
else if (qfp->qf_col == 0)

View File

@ -2405,7 +2405,7 @@ win_line (
/* Highlight the current line in the quickfix window. */
if (bt_quickfix(wp->w_buffer) && qf_current_entry(wp) == lnum)
line_attr = hl_attr(HLF_L);
line_attr = hl_attr(HLF_QFL);
if (line_attr != 0)
area_highlighting = TRUE;
@ -2624,7 +2624,12 @@ win_line (
* then. */
if (wp->w_p_cul && lnum == wp->w_cursor.lnum
&& !(wp == curwin && VIsual_active)) {
line_attr = hl_attr(HLF_CUL);
if (line_attr != 0 && !(State & INSERT) && bt_quickfix(wp->w_buffer)
&& qf_current_entry(wp) == lnum) {
line_attr = hl_combine_attr(hl_attr(HLF_CUL), line_attr);
} else {
line_attr = hl_attr(HLF_CUL);
}
area_highlighting = true;
}

View File

@ -5902,6 +5902,7 @@ static char *highlight_init_both[] =
"VertSplit cterm=reverse gui=reverse",
"WildMenu ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black",
"default link EndOfBuffer NonText",
"default link QuickFixLine Search",
NULL
};

View File

@ -0,0 +1,196 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths
local insert, execute = helpers.insert, helpers.execute
describe('quickfix selection highlight', function()
local screen
before_each(function()
clear()
screen = Screen.new(25, 10)
screen:attach()
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue },
[2] = {reverse = true},
[3] = {foreground = Screen.colors.Brown},
[4] = {bold = true, reverse = true},
[5] = {background = Screen.colors.Green},
[6] = {foreground = Screen.colors.Brown, background = Screen.colors.Green},
[7] = {background = Screen.colors.Red},
[8] = {foreground = Screen.colors.Brown, background = Screen.colors.Red},
[9] = {background = Screen.colors.Fuchsia},
[10] = {foreground = Screen.colors.Red, background = Screen.colors.Fuchsia},
[11] = {foreground = Screen.colors.Red},
[12] = {foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia},
})
meths.set_option('errorformat', '%m %l')
execute('syntax on')
execute('highlight Search guibg=Green')
insert([[
Line 1
Line 2
Line 3
Line 4
Line 5
]])
execute('cad')
feed('gg')
screen:expect([[
^Line 1 |
Line 2 |
Line 3 |
Line 4 |
Line 5 |
|
{1:~ }|
{1:~ }|
{1:~ }|
:cad |
]])
end)
it('using default Search highlight group', function()
execute('copen')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
{5:^|}{6:1}{5:| Line }|
|{3:2}| Line |
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:copen |
]])
execute('cnext')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
|{3:1}| Line |
{5:^|}{6:2}{5:| Line }|
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:cnext |
]])
end)
it('using QuickFixLine highlight group', function()
execute('highlight QuickFixLine guibg=Red')
execute('copen')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
{7:^|}{8:1}{7:| Line }|
|{3:2}| Line |
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:copen |
]])
execute('cnext')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
|{3:1}| Line |
{7:^|}{8:2}{7:| Line }|
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:cnext |
]])
end)
it('combines with CursorLine', function()
execute('set cursorline')
execute('highlight QuickFixLine guifg=Red')
execute('highlight CursorLine guibg=Fuchsia')
execute('copen')
screen:expect([[
{9:Line 1 }|
{2:[No Name] [+] }|
{10:^|1| Line }|
|{3:2}| Line |
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:copen |
]])
feed('j')
screen:expect([[
{9:Line 1 }|
{2:[No Name] [+] }|
{11:|1| Line }|
{9:^|}{12:2}{9:| Line }|
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:copen |
]])
end)
it('QuickFixLine background takes precedence over CursorLine', function()
execute('set cursorline')
execute('highlight QuickFixLine guibg=Red')
execute('highlight CursorLine guibg=Fuchsia')
execute('copen')
screen:expect([[
{9:Line 1 }|
{2:[No Name] [+] }|
{7:^|}{8:1}{7:| Line }|
|{3:2}| Line |
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:copen |
]])
feed('j')
screen:expect([[
{9:Line 1 }|
{2:[No Name] [+] }|
{7:|}{8:1}{7:| Line }|
{9:^|}{12:2}{9:| Line }|
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:copen |
]])
end)
end)