From ae9b76929957a1eb20ea016c6ce9d34bc0d8b213 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Sat, 29 Aug 2020 22:15:40 -0400 Subject: feat: Add selection and start actions --- lua/telescope/pickers.lua | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'lua/telescope/pickers.lua') diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index fc191bd..95476f1 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -193,6 +193,7 @@ function Picker:find(opts) return end + -- TODO: This really isn't the place to do this. local display = entry.display if has_devicons then @@ -200,6 +201,8 @@ function Picker:find(opts) display = (icon or ' ') .. ' ' .. display end + display = ' ' .. display + -- log.info("Setting row", row, "with value", entry) vim.api.nvim_buf_set_lines(results_bufnr, row, row + 1, false, {display}) end @@ -388,17 +391,33 @@ function Picker:set_selection(row) end local status = state.get_status(self.prompt_bufnr) + local results_bufnr = status.results_bufnr + + -- Handle adding '> ' to beginning of selections + if self._selection_row then + a.nvim_buf_set_lines(results_bufnr, self._selection_row, self._selection_row + 1, false, {' ' .. a.nvim_buf_get_lines(results_bufnr, self._selection_row, self._selection_row + 1, false)[1]:sub(3)}) + end + + a.nvim_buf_set_lines(results_bufnr, row, row + 1, false, {'> ' .. a.nvim_buf_get_lines(results_bufnr, row, row + 1, false)[1]:sub(3)}) - a.nvim_buf_clear_namespace(status.results_bufnr, ns_telescope_selection, 0, -1) + a.nvim_buf_clear_namespace(results_bufnr, ns_telescope_selection, 0, -1) a.nvim_buf_add_highlight( - status.results_bufnr, + results_bufnr, ns_telescope_selection, - 'Error', + 'TelescopeSelection', row, 0, -1 ) + + -- if self._match_id then + -- -- vim.fn.matchdelete(self._match_id) + -- vim.fn.clearmatches(results_win) + -- end + + -- self._match_id = vim.fn.matchaddpos("Conceal", { {row + 1, 1, 2} }, 0, -1, { window = results_win, conceal = ">" }) + -- TODO: Don't let you go over / under the buffer limits -- TODO: Make sure you start exactly at the bottom selected -- cgit v1.2.3