diff options
| author | tamago324 <tamago_pad@yahoo.co.jp> | 2020-12-28 01:15:52 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-27 17:15:52 +0100 |
| commit | e555cd375f6c1e384a1c39a9c7c445a1c3aff8e0 (patch) | |
| tree | 673da674f50d4bc3a39594353d044d65662770bf /lua/telescope/make_entry.lua | |
| parent | 3e884e863a37644838037ef5110be6678533667b (diff) | |
feat: all entry_makers are now overridable and icons for builtin.buffers (#364)
Diffstat (limited to 'lua/telescope/make_entry.lua')
| -rw-r--r-- | lua/telescope/make_entry.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 118c321..dba6762 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -33,6 +33,7 @@ local lsp_type_highlight = { local make_entry = {} local transform_devicons +local get_devicons if has_devicons then if not devicons.has_loaded() then devicons.setup() @@ -52,10 +53,27 @@ if has_devicons then return icon_display end end + + get_devicons = function(filename, disable_devicons) + if disable_devicons or not filename then + return '' + end + + local icon, icon_highlight = devicons.get_icon(filename, string.match(filename, '%a+$'), { default = true }) + if conf.color_devicons then + return icon, icon_highlight + else + return icon + end + end else transform_devicons = function(_, display, _) return display end + + get_devicons = function(_, _) + return '' + end end do @@ -426,11 +444,19 @@ end function make_entry.gen_from_buffer(opts) opts = opts or {} + local disable_devicons = opts.disable_devicons + + local icon_width = 0 + if not disable_devicons then + icon_width = vim.fn.strdisplaywidth(get_devicons('fname', disable_devicons)) + end + local displayer = entry_display.create { separator = " ", items = { { width = opts.bufnr_width }, { width = 4 }, + { width = icon_width }, { remaining = true }, }, } @@ -445,9 +471,12 @@ function make_entry.gen_from_buffer(opts) display_bufname = entry.filename end + local icon, hl_group = get_devicons(entry.filename, disable_devicons) + return displayer { {entry.bufnr, "TelescopeResultsNumber"}, {entry.indicator, "TelescopeResultsComment"}, + { icon, hl_group }, display_bufname .. ":" .. entry.lnum } end |
