aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommy Allen <tommy@esdf.io>2016-08-03 16:56:05 -0400
committerTommy Allen <tommy@esdf.io>2016-08-17 17:48:15 -0400
commit605e74327a406682f317d07e0097690fc1e577cb (patch)
treecdc6c3f9ca936c15f6709925f4498baafcce9190
parentdfb6a5133b92ffb38bfb7201e91f3de328652558 (diff)
downloadrneovim-605e74327a406682f317d07e0097690fc1e577cb.tar.gz
rneovim-605e74327a406682f317d07e0097690fc1e577cb.tar.bz2
rneovim-605e74327a406682f317d07e0097690fc1e577cb.zip
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
-rw-r--r--runtime/doc/syntax.txt4
-rw-r--r--runtime/syntax/vim.vim2
-rw-r--r--src/nvim/globals.h3
-rw-r--r--src/nvim/option.c2
-rw-r--r--src/nvim/quickfix.c2
-rw-r--r--src/nvim/screen.c9
-rw-r--r--src/nvim/syntax.c1
-rw-r--r--test/functional/ui/quickfix_spec.lua196
8 files changed, 213 insertions, 6 deletions
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 491e5801c8..d9440b6df8 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -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
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index cf51830b68..c855267137 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -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
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 950ceb4c74..9c32075d40 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -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 */
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 658e0d8a47..e53dbfc75a 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -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.
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index dfd795b0ba..ba2d795eef 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -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)
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index d67142822f..fa8318d83e 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -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;
}
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 3215f7ea14..f7a8e4f8b9 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -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
};
diff --git a/test/functional/ui/quickfix_spec.lua b/test/functional/ui/quickfix_spec.lua
new file mode 100644
index 0000000000..29b28fe9f0
--- /dev/null
+++ b/test/functional/ui/quickfix_spec.lua
@@ -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)