From c414e5f869ec325552e3a4699361da19a365a95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alvaro=20Mu=C3=B1oz?= Date: Fri, 2 Oct 2020 17:26:11 +0200 Subject: [PATCH] feat: Add highlight for selection caret (#135) * Add highlight for selection caret * add default hl * remove highlight overlap --- lua/telescope/pickers.lua | 13 +++++++++++-- plugin/telescope.vim | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index 3bb4c43..8f3483d 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -705,7 +705,8 @@ function Picker:set_selection(row) end end - local display = '> ' .. (a.nvim_buf_get_lines(results_bufnr, row, row + 1, false)[1] or ''):sub(3) + local caret = '>' + local display = string.format('%s %s', caret, (a.nvim_buf_get_lines(results_bufnr, row, row + 1, false)[1] or ''):sub(3)) -- TODO: You should go back and redraw the highlights for this line from the sorter. -- That's the only smart thing to do. @@ -719,9 +720,17 @@ function Picker:set_selection(row) a.nvim_buf_add_highlight( results_bufnr, ns_telescope_selection, - 'TelescopeSelection', + 'TelescopeSelectionCaret', row, 0, + #caret + ) + a.nvim_buf_add_highlight( + results_bufnr, + ns_telescope_selection, + 'TelescopeSelection', + row, + #caret, -1 ) diff --git a/plugin/telescope.vim b/plugin/telescope.vim index 5b8e53a..3fbc8dd 100644 --- a/plugin/telescope.vim +++ b/plugin/telescope.vim @@ -1,6 +1,7 @@ " Sets the highlight for selected items within the picker. highlight default link TelescopeSelection Visual +highlight default link TelescopeSelectionCaret TelescopeSelection highlight default link TelescopeMultiSelection Type " "Normal" in the floating windows created by telescope.