aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/match.c
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@protonmail.com>2022-04-11 22:20:24 +0600
committerFamiu Haque <famiuhaque@protonmail.com>2022-04-17 19:24:59 +0600
commitb16afe4d556af7c3e86b311cfffd1c68a5eed71f (patch)
tree7a7ad533686d93535238adad0c931259a51aa6cc /src/nvim/match.c
parent3f2e9298bdd971a4d2baa298aff7c6f2c2c1ad1a (diff)
downloadrneovim-b16afe4d556af7c3e86b311cfffd1c68a5eed71f.tar.gz
rneovim-b16afe4d556af7c3e86b311cfffd1c68a5eed71f.tar.bz2
rneovim-b16afe4d556af7c3e86b311cfffd1c68a5eed71f.zip
feat(highlight): implement CurSearch highlight
Adds a `CurSearch` highlight group to highlight the current search result under the cursor.
Diffstat (limited to 'src/nvim/match.c')
-rw-r--r--src/nvim/match.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/nvim/match.c b/src/nvim/match.c
index af89319a09..4129e84fc2 100644
--- a/src/nvim/match.c
+++ b/src/nvim/match.c
@@ -4,6 +4,7 @@
// match.c: functions for highlighting matches
#include <stdbool.h>
+#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/fold.h"
#include "nvim/highlight_group.h"
@@ -667,7 +668,16 @@ int update_search_hl(win_T *wp, linenr_T lnum, colnr_T col, char_u **line, match
if (shl->endcol < next_col) {
shl->endcol = next_col;
}
- shl->attr_cur = shl->attr;
+ // Use "CurSearch" highlight for current search match
+ if (shl == search_hl
+ && (HL_ATTR(HLF_LC) || wp->w_hl_ids[HLF_LC])
+ && wp->w_cursor.lnum == lnum
+ && wp->w_cursor.col >= shl->startcol
+ && wp->w_cursor.col < shl->endcol) {
+ shl->attr_cur = win_hl_attr(wp, HLF_LC) ? win_hl_attr(wp, HLF_LC) : HL_ATTR(HLF_LC);
+ } else {
+ shl->attr_cur = shl->attr;
+ }
// Match with the "Conceal" group results in hiding
// the match.
if (cur != NULL