From ca92ec1a830a61a0b88fff925f2146ab46e0f7c9 Mon Sep 17 00:00:00 2001 From: Simon Hauser Date: Sat, 27 Feb 2021 16:26:25 +0100 Subject: 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 - does track the branch - 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 --- lua/telescope/previewers/buffer_previewer.lua | 31 ++++++--------------------- 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'lua/telescope/previewers/buffer_previewer.lua') diff --git a/lua/telescope/previewers/buffer_previewer.lua b/lua/telescope/previewers/buffer_previewer.lua index a6e2322..6fa25de 100644 --- a/lua/telescope/previewers/buffer_previewer.lua +++ b/lua/telescope/previewers/buffer_previewer.lua @@ -466,40 +466,23 @@ previewers.git_branch_log = defaulter(function(opts) end end - local remotes = utils.get_os_command_output({ 'git', 'remote' }, opts.cwd) return previewers.new_buffer_previewer { get_buffer_by_name = function(_, entry) return entry.value end, define_preview = function(self, entry, status) - local current_remote = 1 + local cmd = { 'git', '--no-pager', 'log', '--graph', '--pretty=format:%h -%d %s (%cr)', + '--abbrev-commit', '--date=relative', entry.value } - local gen_cmd = function(v) - return { 'git', '--no-pager', 'log', '--graph', '--pretty=format:%h -%d %s (%cr)', - '--abbrev-commit', '--date=relative', v } - end - - local handle_results - handle_results = function(bufnr, content) - if content and table.getn(content) == 0 then - if current_remote <= table.getn(remotes) then - local value = 'remotes/' .. remotes[current_remote] .. '/' .. entry.value - current_remote = current_remote + 1 - putils.job_maker(gen_cmd(value), bufnr, { cwd = opts.cwd, callback = handle_results }) - else - vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { "No log found for branch: " .. entry.value }) - end - elseif content and table.getn(content) > 1 then - highlight_buffer(bufnr, content) - end - end - - putils.job_maker(gen_cmd(entry.value), self.state.bufnr, { + putils.job_maker(cmd, self.state.bufnr, { value = entry.value, bufname = self.state.bufname, cwd = opts.cwd, - callback = handle_results + callback = function(bufnr, content) + if not content then return end + highlight_buffer(bufnr, content) + end }) end } -- cgit v1.2.3