ibhagwan / fzf-lua

Improved fzf.vim written in lua
MIT License
2.38k stars 151 forks source link

Feature: git.around #1466

Closed GopherJ closed 2 months ago

GopherJ commented 2 months ago

Have you RTFM'd?

Feature Request

sometime while reviewing a commit we would like to jump to commits around the current commit. So it'll be good to highlight the current one and show 3 commits before and 3 commits after

example implementation:

            function garound()
                local current_commit = system("git rev-parse HEAD"):gsub("\n", "")
                local cmd = string.format(
                    "git log --pretty=oneline --reverse --all | rg --color=always --no-line-number -C 3 %s",
                    current_commit
                )
                require("fzf-lua").fzf_exec(cmd, {
                    actions = {
                        ["default"] = function(selected)
                            open_commit_fzf(selected[1])
                        end,
                    },
                })
            end

            vim.api.nvim_create_user_command("GAround", garound, {})
GopherJ commented 2 months ago

btw I didn't see a git show previewer

ibhagwan commented 2 months ago

btw I didn't see a git show previewer

Both git_bcommits and git_blame have git show previewer, maybe this can work with git_bcommits({ cmd = … }).

GopherJ commented 2 months ago

git_bcommits is for file git_around I'd assume the person is in the middle of the commit history and wants to jump next/prev

ibhagwan commented 2 months ago

git_bcommits is for file git_around I'd assume the person is in the middle of the commit history and wants to jump next/prev

Quite honestly I don’t think we need to have a picker in fzf-lua for wfey single git command out there, that’s why it’s all very easy to achieve with fzf_exec.

GopherJ commented 2 months ago

yes just want to see if navigate is a good one to be added by default

ibhagwan commented 2 months ago

yes just want to see if navigate is a good one to be added by default

Maybe you can reuse one of the actions.git_xxx code?

GopherJ commented 1 month ago

sure