Skip to content

Commit 8c3415c

Browse files
feat(make_entry): add icon_separator option
1 parent 5255aa2 commit 8c3415c

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
@@ -154,6 +154,7 @@ do
154154
local cwd = utils.path_expand(opts.cwd or vim.uv.cwd())
155155

156156
local disable_devicons = opts.disable_devicons
157+
local icon_separator = opts.icon_separator
157158

158159
local mt_file_entry = {}
159160

@@ -162,7 +163,7 @@ do
162163
local hl_group, icon
163164
local display, path_style = utils.transform_path(opts, entry.value)
164165

165-
display, hl_group, icon = utils.transform_devicons(entry.value, display, disable_devicons)
166+
display, hl_group, icon = utils.transform_devicons(entry.value, display, disable_devicons, icon_separator)
166167

167168
if hl_group then
168169
local style = { { { 0, #icon + 1 }, hl_group } }
@@ -275,6 +276,7 @@ do
275276
end
276277

277278
local disable_devicons = opts.disable_devicons
279+
local icon_separator = opts.icon_separator
278280
local disable_coordinates = opts.disable_coordinates
279281
local only_sort_text = opts.only_sort_text
280282

@@ -333,7 +335,8 @@ do
333335
local display, hl_group, icon = utils.transform_devicons(
334336
entry.filename,
335337
string.format(display_string, display_filename, coordinates, entry.text),
336-
disable_devicons
338+
disable_devicons,
339+
icon_separator
337340
)
338341

339342
if hl_group then
@@ -587,6 +590,7 @@ function make_entry.gen_from_buffer(opts)
587590
opts = opts or {}
588591

589592
local disable_devicons = opts.disable_devicons
593+
local icon_separator = opts.icon_separator or ""
590594

591595
local icon_width = 0
592596
if not disable_devicons then
@@ -600,6 +604,7 @@ function make_entry.gen_from_buffer(opts)
600604
{ width = opts.bufnr_width },
601605
{ width = 4 },
602606
{ width = icon_width },
607+
{ width = #icon_separator },
603608
{ remaining = true },
604609
},
605610
}
@@ -616,6 +621,7 @@ function make_entry.gen_from_buffer(opts)
616621
{ entry.bufnr, "TelescopeResultsNumber" },
617622
{ entry.indicator, "TelescopeResultsComment" },
618623
{ icon, hl_group },
624+
{ icon_separator },
619625
{
620626
display_bufname .. ":" .. entry.lnum,
621627
function()

lua/telescope/utils.lua

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

618-
return function(filename, display, disable_devicons)
618+
return function(filename, display, disable_devicons, icon_separator)
619+
icon_separator = icon_separator or " "
620+
619621
local conf = require("telescope.config").values
620622
if disable_devicons or not filename then
621623
return display
@@ -627,7 +629,7 @@ utils.transform_devicons = load_once(function()
627629
icon, icon_highlight = devicons.get_icon(basename, nil, { default = true })
628630
icon = icon or " "
629631
end
630-
local icon_display = icon .. " " .. (display or "")
632+
local icon_display = icon .. icon_separator .. (display or "")
631633

632634
if conf.color_devicons then
633635
return icon_display, icon_highlight, icon

0 commit comments

Comments
 (0)