diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2020-10-24 22:55:45 -0400 |
|---|---|---|
| committer | TJ DeVries <devries.timothyj@gmail.com> | 2020-10-24 22:55:45 -0400 |
| commit | a8e780708698a431621a3556a802ca44031d64fd (patch) | |
| tree | 3a5652fab330f4afacba89007f54c12e4f988cfa /lua/telescope/make_entry.lua | |
| parent | 7eda4e80f9fa0b16b2030e81528f17bdaf118041 (diff) | |
feat: Use colors from nvim-devicons
Diffstat (limited to 'lua/telescope/make_entry.lua')
| -rw-r--r-- | lua/telescope/make_entry.lua | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index e765904..46fd3c2 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -14,9 +14,10 @@ if has_devicons then return display end - local icon_display = (devicons.get_icon(filename, string.match(filename, '%a+$')) or ' ') .. ' ' .. display + local icon, icon_highlight = devicons.get_icon(filename, string.match(filename, '%a+$'), { default = true }) + local icon_display = (icon or ' ') .. ' ' .. display - return icon_display + return icon_display, icon_highlight end else transform_devicons = function(_, display, _) @@ -66,12 +67,18 @@ do mt_file_entry.cwd = cwd mt_file_entry.display = function(entry) - local display = entry.value + local display, hl_group = entry.value, nil if shorten_path then display = utils.path_shorten(display) end - return transform_devicons(entry.value, display, disable_devicons) + display, hl_group = transform_devicons(entry.value, display, disable_devicons) + + if hl_group then + return display, { { {1, 3}, hl_group } } + else + return display + end end mt_file_entry.__index = function(t, k) @@ -151,7 +158,7 @@ do mt_vimgrep_entry.cwd = vim.fn.expand(opts.cwd or vim.fn.getcwd()) mt_vimgrep_entry.display = function(entry) - local display = entry.value + local display, hl_group = entry.value, nil local display_filename if shorten_path then @@ -165,13 +172,17 @@ do coordinates = string.format("%s:%s:", entry.lnum, entry.col) end - display = transform_devicons( + display, hl_group = transform_devicons( entry.filename, string.format(display_string, display_filename, coordinates, entry.text), disable_devicons ) - return display + if hl_group then + return display, { { {1, 3}, hl_group } } + else + return display + end end mt_vimgrep_entry.__index = function(t, k) |
