diff --git a/bundle/git.vim/lua/git/ui/branch.lua b/bundle/git.vim/lua/git/ui/branch.lua index a8028638e..4d2cbdeda 100644 --- a/bundle/git.vim/lua/git/ui/branch.lua +++ b/bundle/git.vim/lua/git/ui/branch.lua @@ -103,6 +103,23 @@ local function delete_branch() end end +local function view_log_of_branch() + local remote_line = vim.fn.search('^r:', 'bnW') + if remote_line == 0 then + local line = vim.fn.getline('.') + if vim.startswith(line, ' * ') then + elseif vim.startswith(line, ' ') then + local branch = vim.trim(line) + vim.cmd('tabnew | Git log ' .. branch) + end + else + local line = vim.fn.getline('.') + local branch = vim.trim(line) + local remote = string.sub(vim.fn.getline(remote_line), 3) + vim.cmd('tabnew | Git log ' .. remote .. '/' .. branch) + end +end + function M.open() if branch_manager_bufnr ~= -1 and vim.api.nvim_buf_is_valid(branch_manager_bufnr) then vim.api.nvim_buf_delete(branch_manager_bufnr, { @@ -125,6 +142,9 @@ function M.open() vim.api.nvim_buf_set_keymap(branch_manager_bufnr, 'n', 'dd', '', { callback = delete_branch, }) + vim.api.nvim_buf_set_keymap(branch_manager_bufnr, 'n', 'v', '', { + callback = view_log_of_branch, + }) end function M.update() diff --git a/docs/layers/git.md b/docs/layers/git.md index 2ab116b37..b52731ad7 100644 --- a/docs/layers/git.md +++ b/docs/layers/git.md @@ -58,6 +58,14 @@ if you want to use `fugitive` instead: | `SPC g h r` | undo cursor hunk | | `SPC g h v` | preview cursor hunk | +**Key bindings in Git branch manager:** + +| Key Binding | Description | +| ----------- | ------------------ | +| `v` | view log of branch | +| `Enter` | checkout branch | +| `dd` | delete branch | + ## Omnifunc of commit message This layer also provides omnifunc of commit message. The key binding is `ctrl-x_ctrl-o` in insert mode.