Skip to content

Commit 70d1a94

Browse files
feat(make_entry): add icon_separator option
1 parent b4da76b commit 70d1a94

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

lua/telescope/make_entry.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ do
152152
local cwd = utils.path_expand(opts.cwd or vim.loop.cwd())
153153

154154
local disable_devicons = opts.disable_devicons
155+
local icon_separator = opts.icon_separator
155156

156157
local mt_file_entry = {}
157158

@@ -160,7 +161,7 @@ do
160161
local hl_group, icon
161162
local display, path_style = utils.transform_path(opts, entry.value)
162163

163-
display, hl_group, icon = utils.transform_devicons(entry.value, display, disable_devicons)
164+
display, hl_group, icon = utils.transform_devicons(entry.value, display, disable_devicons, icon_separator)
164165

165166
if hl_group then
166167
local style = { { { 0, #icon + 1 }, hl_group } }
@@ -273,6 +274,7 @@ do
273274
end
274275

275276
local disable_devicons = opts.disable_devicons
277+
local icon_separator = opts.icon_separator
276278
local disable_coordinates = opts.disable_coordinates
277279
local only_sort_text = opts.only_sort_text
278280

@@ -331,7 +333,8 @@ do
331333
local display, hl_group, icon = utils.transform_devicons(
332334
entry.filename,
333335
string.format(display_string, display_filename, coordinates, entry.text),
334-
disable_devicons
336+
disable_devicons,
337+
icon_separator
335338
)
336339

337340
if hl_group then
@@ -585,6 +588,7 @@ function make_entry.gen_from_buffer(opts)
585588
opts = opts or {}
586589

587590
local disable_devicons = opts.disable_devicons
591+
local icon_separator = opts.icon_separator or ""
588592

589593
local icon_width = 0
590594
if not disable_devicons then
@@ -598,6 +602,7 @@ function make_entry.gen_from_buffer(opts)
598602
{ width = opts.bufnr_width },
599603
{ width = 4 },
600604
{ width = icon_width },
605+
{ width = #icon_separator },
601606
{ remaining = true },
602607
},
603608
}
@@ -614,6 +619,7 @@ function make_entry.gen_from_buffer(opts)
614619
{ entry.bufnr, "TelescopeResultsNumber" },
615620
{ entry.indicator, "TelescopeResultsComment" },
616621
{ icon, hl_group },
622+
{ icon_separator },
617623
{
618624
display_bufname .. ":" .. entry.lnum,
619625
function()

lua/telescope/utils.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,9 @@ utils.transform_devicons = load_once(function()
613613
devicons.setup()
614614
end
615615

616-
return function(filename, display, disable_devicons)
616+
return function(filename, display, disable_devicons, icon_separator)
617+
icon_separator = icon_separator or " "
618+
617619
local conf = require("telescope.config").values
618620
if disable_devicons or not filename then
619621
return display
@@ -625,7 +627,7 @@ utils.transform_devicons = load_once(function()
625627
icon, icon_highlight = devicons.get_icon(basename, nil, { default = true })
626628
icon = icon or " "
627629
end
628-
local icon_display = icon .. " " .. (display or "")
630+
local icon_display = icon .. icon_separator .. (display or "")
629631

630632
if conf.color_devicons then
631633
return icon_display, icon_highlight, icon

0 commit comments

Comments
 (0)