Skip to content

Commit

Permalink
feat(git_stash): auto-detect delta previewer
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Mar 7, 2024
1 parent deae3c8 commit 1422822
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lua/fzf-lua/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,15 @@ M.defaults.git = {
actions = { ["default"] = actions.git_checkout },
},
stash = {
prompt = "Stash> ",
cmd = "git --no-pager stash list",
preview = "git --no-pager stash show --patch --color {1}",
actions = {
prompt = "Stash> ",
cmd = "git --no-pager stash list",
preview = "git --no-pager stash show --patch --color {1}",
preview_pager = M._preview_pager_fn,
actions = {
["default"] = actions.git_stash_apply,
["ctrl-x"] = { fn = actions.git_stash_drop, reload = true },
},
fzf_opts = {
fzf_opts = {
-- TODO: multiselect requires more work as dropping
-- a stash changes the stash index, causing an error
-- when the next stash is attempted
Expand Down
7 changes: 7 additions & 0 deletions lua/fzf-lua/providers/git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ M.stash = function(opts)

if opts.preview then
opts.preview = path.git_cwd(opts.preview, opts)
if type(opts.preview_pager) == "function" then
opts.preview_pager = opts.preview_pager()
end
if opts.preview_pager then
opts.preview = string.format("%s | %s", opts.preview,
utils._if_win_normalize_vars(opts.preview_pager))
end
end
if opts.search and opts.search ~= "" then
-- search by stash content, git stash -G<regex>
Expand Down

0 comments on commit 1422822

Please sign in to comment.