From 761adafb54b691d837b87f60e7da539d173abfdc Mon Sep 17 00:00:00 2001 From: Massimo Mund Date: Thu, 7 Aug 2025 21:46:42 +0200 Subject: [PATCH] Add a new colorscheme group for selections within highlighted search results micro allows to set the color for selections and for search results. However, if your color scheme defines a color for highlights that is very similar to your general background color, and you perform a search, the currently selected text will hardly stand out. So add a new color-group analogous to `statusline`, `statusline.inactive`, `statusline.suggestions` --- internal/display/bufwindow.go | 9 ++++++++- runtime/help/colors.md | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/display/bufwindow.go b/internal/display/bufwindow.go index 1ecb43236e..8a9fe09301 100644 --- a/internal/display/bufwindow.go +++ b/internal/display/bufwindow.go @@ -497,7 +497,8 @@ func (w *BufWindow) displayBuffer() { draw := func(r rune, combc []rune, style tcell.Style, highlight bool, showcursor bool) { if nColsBeforeStart <= 0 && vloc.Y >= 0 { if highlight { - if w.Buf.HighlightSearch && w.Buf.SearchMatch(bloc) { + isHighlightSearchMatch := w.Buf.HighlightSearch && w.Buf.SearchMatch(bloc) + if isHighlightSearchMatch { style = config.DefStyle.Reverse(true) if s, ok := config.Colorscheme["hlsearch"]; ok { style = s @@ -552,6 +553,12 @@ func (w *BufWindow) displayBuffer() { if s, ok := config.Colorscheme["selection"]; ok { style = s } + + if isHighlightSearchMatch { + if s, ok := config.Colorscheme["hlsearch.selection"]; ok { + style = s + } + } } if b.Settings["cursorline"].(bool) && w.active && !dontOverrideBackground && diff --git a/runtime/help/colors.md b/runtime/help/colors.md index c085919a93..72c8e4b7f9 100644 --- a/runtime/help/colors.md +++ b/runtime/help/colors.md @@ -198,6 +198,7 @@ Here is a list of the colorscheme groups that you can use: * error-message (Color of error messages in the bottom line of the screen) * match-brace (Color of matching brackets when `matchbracestyle` is set to `highlight`) * hlsearch (Color of highlighted search results when `hlsearch` is enabled) +* hlsearch.selection (Color of the selection within the highlighted search results) * tab-error (Color of tab vs space errors when `hltaberrors` is enabled) * trailingws (Color of trailing whitespaces when `hltrailingws` is enabled)