+ merginal

This commit is contained in:
Stefan Liebl 2015-02-10 16:20:04 +01:00
parent 91ece738cc
commit 121cd1ddca
5 changed files with 1255 additions and 0 deletions

View File

@ -39,3 +39,4 @@ ScriptID SourceID Filename
2830 22798 csv.vim
3849 22637 git-time-lapse
4932 22787 diffchar.vim
4955 22442 Merginal

1052
vimfiles/autoload/merginal.vim Executable file

File diff suppressed because it is too large Load Diff

142
vimfiles/doc/merginal.txt Executable file
View File

@ -0,0 +1,142 @@
*merginal.txt*
Author: Idan Arye <https://github.com/idanarye/>
License: Same terms as Vim itself (see |license|)
Version: 1.4.0
INTRODUCTION *merginal*
Merginal aims provide a nice inteface for dealing with Git branches. It
offers interactive TUI for:
* Viewing the list of branches
* Checking out branches from that list
* Creating new branches
* Deleting branches
* Merging branches
* Rebasing branches
* Solving merge conflicts
* Renaming branches
REQUIREMENTS *merginal-requirements*
Merginal is based on Fugitive, so it requires Fugitive. If you don't have it
already you can get it from https://github.com/tpope/vim-fugitive
It should go without saying that you need Git.
Under Windows, vimproc is an optional requirement. Merginal will work without
it, but it'll pop an ugly console window every time it needs to run a Git
command. You can get vimproc from https://github.com/Shougo/vimproc.vim
USAGE *merginal-usage*
To use Merginal you need to know but one command: *:Merginal*. It'll open the
|merginal-branch-list| buffer, unless the repository is in merge mode then
it'll open the |merginal-merge-conflicts| buffer.
Like Fugitive's commands, |:Merginal| is native to the buffer, and will only
work in buffers that are parts of Git repositories.
You can also toggle the buffer with |:MerginalToggle| or close it with
|:MerginalClose|.
THE BRANCH LIST *merginal-branch-list*
The branch list shows a list of branches. While in that list, you can use the
following keymaps to interact with the branches:
R Refresh the buffer list.
cc Checkout the branch under the cursor.
ct Track the remote branch under the cursor.
cT Track the remote branch under the cursor, prompting for a name.
C Same as cc.
aa Create a new branch from the currently checked out branch. You'll be
prompted to enter a name for the new branch.
A Same as aa.
dd Delete the branch under the cursor.
D Same as dd.
mm Merge the branch under the cursor into the currently checked out
branch. If there are merge conflicts, the |merginal-merge-conflicts|
buffer will open in place of the branch list buffer.
M Same as mm.
mf Merge the branch under the cursor into the currently checked out branch
using Fugitive's |:Gmerge| command.
rb Rebase the currently checked out branch against the branch under the
cursor. If there are rebase conflicts, the |merginal-rebase-conflicts|
buffer will open in place of
the branch list buffer.
ps Prompt to choose a remote to push the branch under the cursor.
pS Prompt to choose a remote to force push the branch under the cursor.
pl Prompt to choose a remote to pull the branch under the cursor.
pf Prompt to choose a remote to fetch the branch under the cursor.
gd Open |merginal-diff-files| buffer to diff against the branch under the
cursor.
rn Prompt to rename the branch under the cursor.
MERGE CONFLICTS *merginal-merge-conflicts*
The merge conflicts buffer is used to solve merge conflicts. It shows all the
files that have merge conflicts and offers the following keymaps:
R Refresh the merge conflicts list.
<Cr> Open the conflicted file under the cursor.
aa Add the conflicted file under the cursor to the staging area. If that
was the last conflicted file, the merge conflicts buffer will close and
|fugitive-:Gstatus| will open.
A Same as aa.
REBASE CONFLICTS *merginal-rebase-conflicts*
The rebase conflicts buffer is used to solve rebase conflicts. It shows the
currently applied commit message and all the files that have rebase conflicts,
and offers the following keymaps:
R Refresh the rebase conflicts list.
<Cr> Open the conflicted file under the cursor.
aa Add the conflicted file under the cursor to the staging area. If that
was the last conflicted file, prompt the user to continue to the next
patch.
A Same as aa.
ra Abort the rebase
rc Continue to the next patch.
rs Skip the current patch
REBASE AMEND *merginal-rebase-amend*
The rebase amend buffer is shown when you amend a patch during a rebase. It
shows the amended commit's shortened hash and commit message. Additionally, it
shows all the branches so you can diff against them while the patch. If offers
the folloing keymaps:
R Refresh the rebase amend buffer.
gd Open |merginal-diff-files| buffer to diff against the branch under the
cursor.
ra Abort the rebase
rc Continue to the next patch.
rs Skip the current patch
DIFF FILES *merginal-diff-files*
The diff files buffer is used to diff against another branch. It displays all
the differences between the currently checked out branch and the branch it was
opened against, and offerts the following keymaps:
R Refresh the diff files list.
<Cr> Open the file under the cursor(if it exists in the currently checked
out branch).
ds Split-diff against the file under the cursor(if it exists in the other
branch)
ds VSplit-diff against the file under the cursor(if it exists in the other
branch)
co Check out the file under the cursor(if it exists in the other branch)
into the current branch.

View File

@ -1940,6 +1940,15 @@ matchit-troubleshoot matchit.txt /*matchit-troubleshoot*
matchit-v_% matchit.txt /*matchit-v_%*
matchit.txt matchit.txt /*matchit.txt*
matchit.vim matchit.txt /*matchit.vim*
merginal merginal.txt /*merginal*
merginal-branch-list merginal.txt /*merginal-branch-list*
merginal-diff-files merginal.txt /*merginal-diff-files*
merginal-merge-conflicts merginal.txt /*merginal-merge-conflicts*
merginal-rebase-amend merginal.txt /*merginal-rebase-amend*
merginal-rebase-conflicts merginal.txt /*merginal-rebase-conflicts*
merginal-requirements merginal.txt /*merginal-requirements*
merginal-usage merginal.txt /*merginal-usage*
merginal.txt merginal.txt /*merginal.txt*
n_<Plug>TComment-Comment tcomment.txt /*n_<Plug>TComment-Comment*
n_<Plug>TComment-Commentb tcomment.txt /*n_<Plug>TComment-Commentb*
n_<Plug>TComment-Commentc tcomment.txt /*n_<Plug>TComment-Commentc*

51
vimfiles/plugin/merginal.vim Executable file
View File

@ -0,0 +1,51 @@
function! s:openBasedOnMergeMode() abort
if merginal#isRebaseMode()
call merginal#openRebaseConflictsBuffer()
elseif merginal#isRebaseAmendMode()
call merginal#openRebaseAmendBuffer()
elseif merginal#isMergeMode()
call merginal#openMergeConflictsBuffer()
else
call merginal#openBranchListBuffer()
endif
endfunction
function! s:toggleBasedOnMergeMode() abort
let l:repo=fugitive#repo()
let l:merginalWindowNumber=bufwinnr('Merginal:')
if 0<=l:merginalWindowNumber
let l:merginalBufferNumber=winbufnr(l:merginalWindowNumber)
let l:merginalBufferName=bufname(l:merginalBufferNumber)
"If we are not on the same dir we need to reload the merginal buffer
"anyways:
if getbufvar(l:merginalBufferNumber,'merginal_repo').dir()==l:repo.dir()
if merginal#isRebaseMode()
if 'Merginal:Rebase'==l:merginalBufferName
call merginal#closeMerginalBuffer()
return
endif
elseif merginal#isRebaseAmendMode()
if 'Merginal:RebaseAmend'==l:merginalBufferName
call merginal#closeMerginalBuffer()
return
endif
elseif merginal#isMergeMode()
if 'Merginal:Conflicts'==l:merginalBufferName
call merginal#closeMerginalBuffer()
return
endif
else
if 'Merginal:Branches'==l:merginalBufferName
call merginal#closeMerginalBuffer()
return
endif
end
endif
endif
call s:openBasedOnMergeMode()
endfunction
autocmd User Fugitive command! -buffer -nargs=0 Merginal call s:openBasedOnMergeMode()
autocmd User Fugitive command! -buffer -nargs=0 MerginalToggle call s:toggleBasedOnMergeMode()
autocmd User Fugitive command! -buffer -nargs=0 MerginalClose call merginal#closeMerginalBuffer()