diff options
| author | Simon Hauser <Simon-Hauser@outlook.de> | 2021-02-27 16:26:25 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-27 16:26:25 +0100 |
| commit | ca92ec1a830a61a0b88fff925f2146ab46e0f7c9 (patch) | |
| tree | 4d30266573d6a009280ba9c31348b9ea76f3daec /lua/telescope/builtin/git.lua | |
| parent | 84732d1d780f1aecb799502be97ec3a403066268 (diff) | |
fix: a lot of small things and adds more customization for caret (#554)
Attention:
prompt_prefix will no longer add a space at the end. So if you still want a space at the end make sure your configuration has one.
The default should not be changed. So if you haven't copied prompt_prefix in your config this doesn't affect you.
Feat:
- prompt prefix does no longer always end with space
- selection_caret configurable. Default: `> `
- result_prefix configurable. Default: ` `
- more actions for git_branches
- <c-t> does track the branch
- <c-r> does rebase branch
- also added delete branch action but not configured. See readme on how to do that
Fixes:
- fix docgen ci
- Better error for lsp_workspace_symbols
- better formatting for CONTRIBUTING.md
- move from systemlist to plenary.job
- git branch now supports checkout on remote branches
Diffstat (limited to 'lua/telescope/builtin/git.lua')
| -rw-r--r-- | lua/telescope/builtin/git.lua | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lua/telescope/builtin/git.lua b/lua/telescope/builtin/git.lua index a296517..c333159 100644 --- a/lua/telescope/builtin/git.lua +++ b/lua/telescope/builtin/git.lua @@ -79,20 +79,15 @@ end git.branches = function(opts) local output = utils.get_os_command_output({ 'git', 'branch', '--all' }, opts.cwd) - local tmp_results = {} + 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/[^/]*/', '') - tmp_results[v] = true + v = string.gsub(v, '^remotes/', '') + table.insert(results, v) end end - local results = {} - for k, _ in pairs(tmp_results) do - table.insert(results, k) - end - pickers.new(opts, { prompt_title = 'Git Branches', finder = finders.new_table { @@ -103,8 +98,13 @@ git.branches = function(opts) }, previewer = previewers.git_branch_log.new(opts), sorter = conf.file_sorter(opts), - attach_mappings = function() + attach_mappings = function(_, map) actions.select_default:replace(actions.git_checkout) + map('i', '<c-t>', actions.git_track_branch) + map('n', '<c-t>', actions.git_track_branch) + + map('i', '<c-r>', actions.git_rebase_branch) + map('n', '<c-r>', actions.git_rebase_branch) return true end }):find() @@ -155,14 +155,14 @@ local set_opts_cwd = function(opts) end -- Find root of git directory and remove trailing newline characters - local git_root = vim.fn.systemlist("git -C " .. opts.cwd .. " rev-parse --show-toplevel")[1] + local git_root, ret = utils.get_os_command_output({ "git", "rev-parse", "--show-toplevel" }, opts.cwd) local use_git_root = utils.get_default(opts.use_git_root, true) - if vim.v.shell_error ~= 0 then + if ret ~= 0 then error(opts.cwd .. ' is not a git directory') else if use_git_root then - opts.cwd = git_root + opts.cwd = git_root[1] end end end |
