diff options
| author | Luke Kershaw <35707277+l-kershaw@users.noreply.github.com> | 2022-01-05 22:42:29 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-05 22:42:29 +0000 |
| commit | f285599440fcdbf97a7f44d120d403c80316f576 (patch) | |
| tree | 1f957e086e1f07516c234ecd3e49657ab664744f /lua/telescope/pickers/highlights.lua | |
| parent | 749ce3b8ca1989ce5a7f9a062b7c21f38f1a6d83 (diff) | |
feat: multiselect icon (#1572)
* feat: add `multi_icon` option to pickers and corresponding highlight
* feat: allow `multi_icon` to be any length
* fix: adjust `selection_caret` highlighting
Diffstat (limited to 'lua/telescope/pickers/highlights.lua')
| -rw-r--r-- | lua/telescope/pickers/highlights.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lua/telescope/pickers/highlights.lua b/lua/telescope/pickers/highlights.lua index 6d89b78..3ac6510 100644 --- a/lua/telescope/pickers/highlights.lua +++ b/lua/telescope/pickers/highlights.lua @@ -84,6 +84,20 @@ function Highlighter:hi_multiselect(row, is_selected) if is_selected then vim.api.nvim_buf_add_highlight(results_bufnr, ns_telescope_multiselection, "TelescopeMultiSelection", row, 0, -1) + if self.picker.multi_icon then + local line = vim.api.nvim_buf_get_lines(results_bufnr, row, row + 1, false)[1] + local pos = line:find(self.picker.multi_icon) + if pos and pos <= math.max(#self.picker.selection_caret, #self.picker.entry_prefix) then + vim.api.nvim_buf_add_highlight( + results_bufnr, + ns_telescope_multiselection, + "TelescopeMultiIcon", + row, + pos - 1, + pos - 1 + #self.picker.multi_icon + ) + end + end else local existing_marks = vim.api.nvim_buf_get_extmarks( results_bufnr, |
