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 = {}
for _, v in ipairs(output) do
if not string.match(v, 'HEAD') and v ~= '' then
v = string.gsub(v, '.* ', '')
v = string.gsub(v, '^remotes/', '')
if vim.startswith(v, '*') then
table.insert(results, 1, v)
else
table.insert(results, v)
end
end
end
pickers.new(opts, {
prompt_title = 'Git Branches',
finder = finders.new_table {
results = results,
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
},
previewer = previewers.git_branch_log.new(opts),