diff options
| author | Simon Hauser <Simon-Hauser@outlook.de> | 2021-03-01 22:36:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-01 22:36:37 +0100 |
| commit | b08f65c5fd25c752da0ed909349d613875f573ca (patch) | |
| tree | a380d1aae0567e9de536911c3f0092db80f95c52 /lua | |
| parent | 50ae42b158dbd487dce9b4cf392a954efd79d02b (diff) | |
feat: better display for git_branches (#586)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/builtin/git.lua | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lua/telescope/builtin/git.lua b/lua/telescope/builtin/git.lua index bf41379..98551ca 100644 --- a/lua/telescope/builtin/git.lua +++ b/lua/telescope/builtin/git.lua @@ -82,9 +82,11 @@ 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/', '') - table.insert(results, v) + if vim.startswith(v, '*') then + table.insert(results, 1, v) + else + table.insert(results, v) + end end end @@ -93,7 +95,14 @@ git.branches = function(opts) 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), |
