diff options
Diffstat (limited to 'lua/telescope/pickers/entry_display.lua')
| -rw-r--r-- | lua/telescope/pickers/entry_display.lua | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/lua/telescope/pickers/entry_display.lua b/lua/telescope/pickers/entry_display.lua index 2a156b6..a6bf8f9 100644 --- a/lua/telescope/pickers/entry_display.lua +++ b/lua/telescope/pickers/entry_display.lua @@ -1,46 +1,5 @@ -local log = require('telescope.log') - local entry_display = {} --- index are used to determine the correct order --- elements = { --- [1] = { element, max width }, -- max width should be greater than 0 --- [2] = { a, 0 } -- Use 0 to disable max width --- [3] = { b, 0 } -- If b is nil, skip this column, should skip column for all rows --- }, --- separator = " " -- either arbitrary string, when you wanna use the same separator between all elements --- separator = { " ", ":" } -- or table, where [1] is separator between elements[1] and elements[2], etc - --- TODO: Remove this and move ONLY to create method. - -local table_format = function(picker, elements, separator) - -- TODO: Truncate... - local win_width = vim.api.nvim_win_get_width(picker.results_win) - - local output = "" - for k, v in ipairs(elements) do - local text = v[1] - local width = v[2] - if text ~= nil then - if k > 1 then - output = output .. (type(separator) == "table" and separator[k - 1] or separator) - end - if width then - if width == 0 then - output = output .. string.format("%s", text) - elseif width < 1 then - output = output .. string.format("%-" .. math.floor(width * win_width) .. "s", text) - else - output = output .. string.format("%-" .. width .."s", text) - end - else - output = output .. text - end - end - end - return output -end - local function truncate(str, len) -- TODO: This doesn't handle multi byte chars... if vim.fn.strdisplaywidth(str) > len then @@ -94,9 +53,10 @@ entry_display.create = function(configuration) if configuration.separator_hl then local width = #configuration.separator or 1 - local hl_start, hl_end = 0, 0 + + local hl_start, hl_end for _, v in ipairs(results) do - hl_start = hl_end + #tostring(v) + hl_start = (hl_end or 0) + #tostring(v) hl_end = hl_start + width table.insert(highlights, { { hl_start, hl_end }, configuration.separator_hl }) end @@ -122,8 +82,6 @@ entry_display.resolve = function(self, entry) if type(display) == 'string' then return display, display_highlights - elseif type(display) == 'table' then - return table_format(self, display, "│"), display_highlights end end |
