From 1278173acf49fa2910832df282460d8e1f6bfbbd Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 28 Aug 2020 00:32:55 -0400 Subject: [PATCH] Add devicons if u got em. Rockerboo plz adds docs. Much love. Bed time NOW! --- lua/telescope/pickers.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index b5e418a..3350192 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -10,6 +10,8 @@ local Entry = require('telescope.entry') local Sorter = require('telescope.sorters').Sorter local Previewer = require('telescope.previewers').Previewer +local has_devicons, devicons = pcall(require, 'nvim-web-devicons') + local pickers = {} local ifnil = function(x, was_nil, was_not_nil) if x == nil then return was_nil else return was_not_nil end end @@ -191,8 +193,15 @@ function Picker:find(opts) return end + local display = entry.display + + if has_devicons then + local icon = devicons.get_icon(display, vim.fn.fnamemodify(display, ":e")) + display = (icon or ' ') .. ' ' .. display + end + -- log.info("Setting row", row, "with value", entry) - vim.api.nvim_buf_set_lines(results_bufnr, row, row + 1, false, {entry.display}) + vim.api.nvim_buf_set_lines(results_bufnr, row, row + 1, false, {display}) end ))