1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 07:00:04 +08:00

perf(git): add key binding v to view log

This commit is contained in:
Eric Wong 2024-07-02 16:52:39 +08:00
parent 16b8430918
commit 305e4545ec
2 changed files with 28 additions and 0 deletions

View File

@ -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()

View File

@ -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.