feat: better display for git_branches (#586)

This commit is contained in:
Simon Hauser
2021-03-01 22:36:37 +01:00
committed by GitHub
parent 50ae42b158
commit b08f65c5fd

View File

@@ -82,18 +82,27 @@ git.branches = function(opts)
local results = {} local results = {}
for _, v in ipairs(output) do for _, v in ipairs(output) do
if not string.match(v, 'HEAD') and v ~= '' then if not string.match(v, 'HEAD') and v ~= '' then
v = string.gsub(v, '.* ', '') if vim.startswith(v, '*') then
v = string.gsub(v, '^remotes/', '') table.insert(results, 1, v)
else
table.insert(results, v) table.insert(results, v)
end end
end end
end
pickers.new(opts, { pickers.new(opts, {
prompt_title = 'Git Branches', prompt_title = 'Git Branches',
finder = finders.new_table { finder = finders.new_table {
results = results, results = results,
entry_maker = function(entry) entry_maker = function(entry)
return { value = entry, ordinal = entry, display = entry, } local addition = vim.startswith(entry, '*') and '* ' or ' '
entry = entry:gsub('[* ] ', '')
entry = entry:gsub('^remotes/', '')
return {
value = entry,
ordinal = addition .. entry,
display = addition .. entry
}
end end
}, },
previewer = previewers.git_branch_log.new(opts), previewer = previewers.git_branch_log.new(opts),