diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2020-09-03 23:56:49 -0400 |
|---|---|---|
| committer | TJ DeVries <devries.timothyj@gmail.com> | 2020-09-03 23:56:49 -0400 |
| commit | 839f57efb37cba7a9542b67b31370e1babaf194a (patch) | |
| tree | 2e502a58d83bc528e78b3d44d92134ec96d1345a /lua/telescope/pickers.lua | |
| parent | 737363097b8710566cf624776f1d0a18c03a0d8b (diff) | |
feat: Major improvements in API. Particularly relating to entries.
Diffstat (limited to 'lua/telescope/pickers.lua')
| -rw-r--r-- | lua/telescope/pickers.lua | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index 23b5917..f109db7 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -1,6 +1,5 @@ local a = vim.api local popup = require('popup') -local has_devicons, devicons = pcall(require, 'nvim-web-devicons') local actions = require('telescope.actions') local log = require('telescope.log') @@ -8,8 +7,6 @@ local mappings = require('telescope.mappings') local state = require('telescope.state') local utils = require('telescope.utils') -local Entry = require('telescope.entry') - local get_default = utils.get_default -- TODO: Make this work with deep extend I think. @@ -255,14 +252,19 @@ function Picker:find() return end - -- TODO: This really isn't the place to do this. - local display = entry.display - - if has_devicons then - local icon = devicons.get_icon(display, vim.fn.fnamemodify(display, ":e")) - display = (icon or ' ') .. ' ' .. display + local display + if type(entry.display) == 'function' then + display = entry:display() + elseif type(entry.display) == 'string' then + display = entry.display + else + log.info("Weird entry", entry) + return end + -- This is the two spaces to manage the '> ' stuff. + -- Maybe someday we can use extmarks or floaty text or something to draw this and not insert here. + -- until then, insert two spaces display = ' ' .. display -- log.info("Setting row", row, "with value", entry) @@ -277,10 +279,9 @@ function Picker:find() end )) - local process_result = function(line) - local entry = Entry:new(line) - - if not entry.valid then + local process_result = function(entry) + -- TODO: Should we even have valid? + if entry.valid == false then return end @@ -559,10 +560,7 @@ pickers.entry_manager = function(max_results, set_entry) return setmetatable({ add_entry = function(self, score, entry) - -- TODO: Consider forcing people to make these entries before we add them. - if type(entry) == "string" then - entry = Entry:new(entry) - end + assert(type(entry) == "table", "entry must be a table by the time it reaches here") score = score or 0 @@ -647,6 +645,10 @@ function pickers.on_close_prompt(prompt_bufnr) local picker = status.picker picker:close_windows(status) + + if picker.previewer then + picker.previewer:teardown() + end end |
