Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions lua/telescope/make_entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1019,28 +1019,51 @@ function make_entry.gen_from_autocommands(_)
end
end

local git_icon_defaults = {
added = "+",
changed = "~",
copied = ">",
deleted = "-",
renamed = "➡",
unmerged = "‡",
untracked = "?"
}

function make_entry.gen_from_git_status(opts)
opts = opts or {}

local col_width = ((opts.git_icons and opts.git_icons.added) and opts.git_icons.added:len() + 2) or 2
local displayer = entry_display.create {
separator = " ",
separator = "",
items = {
{ width = 1 },
{ width = 1 },
{ width = col_width},
{ width = col_width},
{ remaining = true },
}
}

local make_display = function(entry)
local modified = "TelescopeResultsDiffChange"
local staged = "TelescopeResultsDiffAdd"
local icons = vim.tbl_extend("keep", opts.git_icons or {}, git_icon_defaults)

if entry.status == "??" then
modified = "TelescopeResultsDiffDelete"
staged = "TelescopeResultsDiffDelete"
end
local git_abbrev = {
["A"] = {icon = icons.added, hl = "TelescopeResultsDiffAdd"},
["U"] = {icon = icons.unmerged, hl = "TelescopeResultsDiffAdd"},
["M"] = {icon = icons.changed, hl = "TelescopeResultsDiffChange"},
["C"] = {icon = icons.copied, hl = "TelescopeResultsDiffChange"},
["R"] = {icon = icons.renamed, hl = "TelescopeResultsDiffChange"},
["D"] = {icon = icons.deleted, hl = "TelescopeResultsDiffDelete"},
["?"] = {icon = icons.untracked, hl = "TelescopeResultsDiffUntracked"},
}

local make_display = function(entry)
local x = string.sub(entry.status, 1, 1)
local y = string.sub(entry.status, -1)
local status_x = git_abbrev[x] or {}
local status_y = git_abbrev[y] or {}

local empty_space = (" ")
return displayer {
{ string.sub(entry.status, 1, 1), staged },
{ string.sub(entry.status, -1), modified },
{ status_x.icon or empty_space, status_x.hl},
{ status_y.icon or empty_space, status_y.hl},
entry.value,
}
end
Expand Down
1 change: 1 addition & 0 deletions plugin/telescope.vim
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ highlight default link TelescopeResultsSpecialComment SpecialComment
highlight default link TelescopeResultsDiffChange DiffChange
highlight default link TelescopeResultsDiffAdd DiffAdd
highlight default link TelescopeResultsDiffDelete DiffDelete
highlight default link TelescopeResultsDiffUntracked NonText

" This is like "<C-R>" in your terminal.
" To use it, do `cmap <C-R> <Plug>(TelescopeFuzzyCommandSearch)
Expand Down
36 changes: 0 additions & 36 deletions scratch/old_perf_debug

This file was deleted.