Skip to content

Commit

Permalink
Merge pull request #964 from NeogitOrg/prompt-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
CKolkey authored Nov 22, 2023
2 parents a4a45a4 + 8c2b144 commit 809187d
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 19 deletions.
8 changes: 6 additions & 2 deletions lua/neogit/lib/finder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ Finder.__index = Finder
---@param opts FinderOpts
---@return Finder
function Finder:new(opts)
if opts.prompt_prefix then
opts.prompt_prefix = string.format(" %s > ", opts.prompt_prefix)
end

local this = {
opts = vim.tbl_deep_extend("keep", opts, default_opts()),
entries = {},
Expand Down Expand Up @@ -210,7 +214,7 @@ function Finder:find(on_select)
elseif config.check_integration("fzf_lua") then
local fzf_lua = require("fzf-lua")
fzf_lua.fzf_exec(self.entries, {
prompt = self.opts.prompt_prefix,
prompt = string.format(" %s > ", self.opts.prompt_prefix),
fzf_opts = fzf_opts(self.opts),
winopts = {
height = self.opts.layout_config.height,
Expand All @@ -219,7 +223,7 @@ function Finder:find(on_select)
})
else
vim.ui.select(self.entries, {
prompt = self.opts.prompt_prefix,
prompt = string.format(" %s > ", self.opts.prompt_prefix),
format_item = function(entry)
return entry
end,
Expand Down
2 changes: 1 addition & 1 deletion lua/neogit/lib/git/branch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function M.set_pushRemote()
elseif pushDefault:is_set() then
pushRemote = pushDefault:read()
else
pushRemote = FuzzyFinderBuffer.new(remotes):open_async { prompt_prefix = "set pushRemote > " }
pushRemote = FuzzyFinderBuffer.new(remotes):open_async { prompt_prefix = "set pushRemote" }
end

if pushRemote then
Expand Down
6 changes: 3 additions & 3 deletions lua/neogit/popups/branch/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ M.checkout_local_branch = operation("checkout_local_branch", function(popup)
end)

local target = FuzzyFinderBuffer.new(util.merge(local_branches, remote_branches)):open_async {
prompt_prefix = " branch > ",
prompt_prefix = "branch",
}

if target then
Expand Down Expand Up @@ -116,7 +116,7 @@ M.checkout_create_branch = operation("checkout_create_branch", function()
end
name, _ = name:gsub("%s", "-")

local base_branch = FuzzyFinderBuffer.new(branches):open_async { prompt_prefix = " base branch > " }
local base_branch = FuzzyFinderBuffer.new(branches):open_async { prompt_prefix = "base branch" }
if not base_branch then
return
end
Expand Down Expand Up @@ -180,7 +180,7 @@ M.reset_branch = operation("reset_branch", function()
local current = git.branch.current()
local branches = git.branch.get_all_branches(false)
local to = FuzzyFinderBuffer.new(branches):open_async {
prompt_prefix = string.format(" reset %s to > ", current),
prompt_prefix = string.format("reset %s to", current),
}

if not to then
Expand Down
2 changes: 1 addition & 1 deletion lua/neogit/popups/branch_config/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function M.merge_config(branch)
local branches = util.merge(local_branches, remote_branches)

return a.void(function(popup, c)
local target = FuzzyFinderBuffer.new(branches):open_async { prompt_prefix = "Upstream > " }
local target = FuzzyFinderBuffer.new(branches):open_async { prompt_prefix = "upstream" }
if not target then
return
end
Expand Down
6 changes: 3 additions & 3 deletions lua/neogit/popups/fetch/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local util = require("neogit.lib.util")
local FuzzyFinderBuffer = require("neogit.buffers.fuzzy_finder")

local function select_remote()
return FuzzyFinderBuffer.new(git.remote.list()):open_async { prompt_prefix = "remote > " }
return FuzzyFinderBuffer.new(git.remote.list()):open_async { prompt_prefix = "remote" }
end

local function fetch_from(name, remote, branch, args)
Expand Down Expand Up @@ -86,7 +86,7 @@ function M.fetch_another_branch(popup)
end)

local branch = FuzzyFinderBuffer.new(branches):open_async {
prompt_prefix = remote .. "/{branch} > ",
prompt_prefix = remote .. "/{branch}",
}
if not branch then
return
Expand All @@ -107,7 +107,7 @@ function M.fetch_refspec(popup)
end)
notification.delete_all()

local refspec = FuzzyFinderBuffer.new(refspecs):open_async { prompt_prefix = "refspec > " }
local refspec = FuzzyFinderBuffer.new(refspecs):open_async { prompt_prefix = "refspec" }
if not refspec then
return
end
Expand Down
2 changes: 1 addition & 1 deletion lua/neogit/popups/ignore/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end
---@param rules string[]
local function add_rules(path, rules)
local selected = FuzzyFinderBuffer.new(rules)
:open_async { allow_multi = true, prompt_prefix = " File or pattern to ignore > " }
:open_async { allow_multi = true, prompt_prefix = "File or pattern to ignore" }

if not selected or #selected == 0 then
return
Expand Down
4 changes: 2 additions & 2 deletions lua/neogit/popups/pull/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function M.from_upstream(popup)
if not upstream then
set_upstream = true
upstream = FuzzyFinderBuffer.new(git.branch.get_remote_branches()):open_async {
prompt_prefix = "set upstream > ",
prompt_prefix = "set upstream",
}

if not upstream then
Expand All @@ -63,7 +63,7 @@ end

function M.from_elsewhere(popup)
local target = FuzzyFinderBuffer.new(git.branch.get_all_branches(false))
:open_async { prompt_prefix = "pull > " }
:open_async { prompt_prefix = "pull" }
if not target then
return
end
Expand Down
10 changes: 5 additions & 5 deletions lua/neogit/popups/push/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function M.to_upstream(popup)
set_upstream = true
branch = git.branch.current()
remote = git.branch.upstream_remote()
or FuzzyFinderBuffer.new(git.remote.list()):open_async { prompt_prefix = "remote > " }
or FuzzyFinderBuffer.new(git.remote.list()):open_async { prompt_prefix = "remote" }
end

if remote then
Expand All @@ -69,7 +69,7 @@ end

function M.to_elsewhere(popup)
local target = FuzzyFinderBuffer.new(git.branch.get_remote_branches()):open_async {
prompt_prefix = "push > ",
prompt_prefix = "push",
}

if target then
Expand All @@ -87,7 +87,7 @@ function M.push_other(popup)
table.insert(sources, 1, popup.state.env.commit)
end

local source = FuzzyFinderBuffer.new(sources):open_async { prompt_prefix = "push > " }
local source = FuzzyFinderBuffer.new(sources):open_async { prompt_prefix = "push" }
if not source then
return
end
Expand All @@ -98,7 +98,7 @@ function M.push_other(popup)
end

local destination = FuzzyFinderBuffer.new(destinations)
:open_async { prompt_prefix = "push " .. source .. " to > " }
:open_async { prompt_prefix = "push " .. source .. " to" }
if not destination then
return
end
Expand All @@ -114,7 +114,7 @@ function M.push_tags(popup)
if #remotes == 1 then
remote = remotes[1]
else
remote = FuzzyFinderBuffer.new(remotes):open_async { prompt_prefix = "push tags to > " }
remote = FuzzyFinderBuffer.new(remotes):open_async { prompt_prefix = "push tags to" }
end

if remote then
Expand Down
2 changes: 1 addition & 1 deletion lua/neogit/popups/tag/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ end
---@param _ table
function M.prune(_)
local selected_remote = FuzzyFinderBuffer.new(git.remote.list()):open_async {
prompt_prefix = " Prune tags using remote > ",
prompt_prefix = "Prune tags using remote",
}

if (selected_remote or "") == "" then
Expand Down

0 comments on commit 809187d

Please sign in to comment.