Skip to content

Commit bca6f8c

Browse files
committed
feat(git): reflog picker
fix(cli): commits<->diff<->hunks actions fix(hunks): with bat previewer
1 parent 14e2ebc commit bca6f8c

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ Fzf-Lua conveniently comes with a VS-Code like picker by default
267267
| `git_status` | `git status` |
268268
| `git_diff` | `git diff {ref}` |
269269
| `git_hunks` | `git hunks {ref}` |
270+
| `git_reflog` | `git reflog` |
270271
| `git_commits` | git commit log (project) |
271272
| `git_bcommits` | git commit log (buffer) |
272273
| `git_blame` | git blame (buffer) |

lua/fzf-lua/defaults.lua

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ M.defaults.global = vim.tbl_deep_extend("force", M.defaults.files, {
613613
---@field status fzf-lua.config.GitStatus
614614
---@field diff fzf-lua.config.GitDiff
615615
---@field hunks fzf-lua.config.GitHunks
616+
---@field reflog fzf-lua.config.GitReflog
616617
---@field commits fzf-lua.config.GitCommits
617618
---@field bcommits fzf-lua.config.GitBcommits
618619
---@field blame fzf-lua.config.GitBlame
@@ -695,7 +696,8 @@ M.defaults.git = {
695696
FzfLua.git_hunks(o)
696697
end,
697698
header = "git hunks",
698-
exec_silent = true,
699+
reuse = #vim.api.nvim_list_uis() == 0,
700+
exec_silent = #vim.api.nvim_list_uis() > 0,
699701
field_index = "{} $FZF_POS",
700702
},
701703
["ctrl-q"] = {
@@ -732,6 +734,7 @@ M.defaults.git = {
732734
["--delimiter"] = ":",
733735
["--nth"] = "3..",
734736
},
737+
line_field_index = "{2}",
735738
_fzf_nth_devicons = true,
736739
_actions = function() return M.globals.actions.files end,
737740
_headers = { "cwd", "actions" },
@@ -763,7 +766,8 @@ M.defaults.git = {
763766
FzfLua.git_diff(o)
764767
end,
765768
header = "git diff",
766-
exec_silent = true,
769+
reuse = #vim.api.nvim_list_uis() == 0,
770+
exec_silent = #vim.api.nvim_list_uis() > 0,
767771
field_index = "{} $FZF_POS",
768772
},
769773
},
@@ -895,6 +899,13 @@ M.defaults.git = {
895899
},
896900
}
897901

902+
---Git reflog.
903+
---@diagnostic disable-next-line: param-type-mismatch
904+
---@class fzf-lua.config.GitReflog: fzf-lua.config.GitCommits
905+
M.defaults.git.reflog = vim.tbl_deep_extend("force", M.defaults.git.commits, {
906+
cmd = [[git reflog --color=always --format="%C(yellow)%h %C(blue)%gD%C(auto)%d %gs"]],
907+
})
908+
898909
---Jujutsu pickers parent table.
899910
---@class fzf-lua.config.Jj
900911
---@field files fzf-lua.config.JjFiles

lua/fzf-lua/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ local lazyloaded_modules = {
257257
git_diff = { "fzf-lua.providers.git", "diff" },
258258
git_hunks = { "fzf-lua.providers.git", "hunks" },
259259
git_stash = { "fzf-lua.providers.git", "stash" },
260+
git_reflog = { "fzf-lua.providers.git", "reflog" },
260261
git_commits = { "fzf-lua.providers.git", "commits" },
261262
git_bcommits = { "fzf-lua.providers.git", "bcommits" },
262263
git_blame = { "fzf-lua.providers.git", "blame" },

lua/fzf-lua/providers/git.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ M.commits = function(opts)
185185
return git_cmd(opts)
186186
end
187187

188+
---@param opts fzf-lua.config.GitReflog|{}?
189+
---@return thread?, string?, table?
190+
M.reflog = function(opts)
191+
---@type fzf-lua.config.GitReflog
192+
opts = config.normalize_opts(opts, "git.reflog")
193+
if not opts then return end
194+
opts.preview = git_preview(opts)
195+
return git_cmd(opts)
196+
end
197+
188198
---@param opts fzf-lua.config.GitBcommits|{}?
189199
---@return thread?, string?, table?
190200
M.bcommits = function(opts)

0 commit comments

Comments
 (0)