Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jreybert/vimagit into next
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/jreybert/vimagit:
  plugin/magit.vim: add reset mapping in diff context ref #97
  README.md
  plugin/magit.vim: enlarge or shrink hunks fix #97
  doc/vimagit.txt: add vimagit-g:magit_jump_{next,prev}_hunk variable links fix #87
  Add Gitter badge
  • Loading branch information
jreybert committed Oct 14, 2016
2 parents 0f30644 + 4a067f2 commit 4b53e6a
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 44 deletions.
100 changes: 58 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# vimagit

[![Join the chat at https://gitter.im/jreybert/vimagit](https://badges.gitter.im/jreybert/vimagit.svg)](https://gitter.im/jreybert/vimagit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Master build status](https://travis-ci.org/jreybert/vimagit.svg?branch=master)](https://travis-ci.org/jreybert/vimagit/branches)

Ease your git worflow within vim.

From a very single vim buffer, you can perform main git operations in few key press. To name a few:
* Visualize all diffs in your git repository.
* Stage file, hunks or even just parts of a hunk using a single key press.
* Write or amend your commit message and commit in the same buffer.

Take a look at [TL;DR](#tldr) to start using it immediately.

![Example of vimagit 1.5.1](../gh-pages/images/vimagit_screenshot_1.5.1.png?raw=true "Example of vimagit 1.5.1")

Some screencasts:
Expand All @@ -15,8 +20,6 @@ Some screencasts:

This workflow is 100% inspired from magnificent emacs [Magit](https://github.com/magit/magit) plugin.

Take a look at [TL;DR](#tldr) to start using it immediately.

## Outstanding features

* [x] Preview all your git changes in one unique buffer, folded at hunk level.
Expand All @@ -25,6 +28,7 @@ Take a look at [TL;DR](#tldr) to start using it immediately.
* [x] Write the commit message in the same buffer.
* [x] From a hunk in magit buffer, jump to the file at the diff position.
* [x] Update vim-gitgutter signs when git status is updated.
* [x] 100% VimL plugin, no external dependency (except git of course).
* [x] Stable. All features are tested in continuous integration.

More to come:
Expand All @@ -41,44 +45,43 @@ More to come:
* fugitive is a very complete plugin, with a lot of functions. I use it for years, and it is a fundamental tool in my workflow. But visualize your changes and staged them in broad number of files is really a pain.
* vim-gitgutter is very well integrated into vim, but without the ability to commit stages, it stays an informational plugin.

## Integration

Branches [master](https://github.com/jreybert/vimagit/) and [next](https://github.com/jreybert/vimagit/tree/next) are continuously tested on [travis](https://travis-ci.org/jreybert/vimagit) when published on github.

vimagit is tested with various versions of vim on linux: vim 7.3.249, vim 7.4.273, and latest neovim version. It is also tested for macos X: vim, macvim and neovim. Anyway, if you feel that vimagit behaves oddly (slow refresh, weird display order...) please fill an [issue](https://github.com/jreybert/vimagit/issues/new).

For the most enthusiastic, you can try the branch [next](https://github.com/jreybert/vimagit/tree/next). It is quite stable, just check its travis status before fetching it.

Travis status:
* **[master status](https://travis-ci.org/jreybert/vimagit/branches)**: [![Master build status](https://travis-ci.org/jreybert/vimagit.svg?branch=master)](https://travis-ci.org/jreybert/vimagit/branches)
* **[next status](https://travis-ci.org/jreybert/vimagit/branches)**: [![next build status](https://travis-ci.org/jreybert/vimagit.svg?branch=next)](https://travis-ci.org/jreybert/vimagit/branches)

A lot a features are developed in dev/feature_name branches. While it may be asked to users to test these branches (during a bug fix for example), one is warned that these branches may be heavily rebased/deleted.

## TL;DR

This is the minimal required set of command you must know to start playing with vimagit. See [Mapping](#mapping) for a complete description.
This is the minimal required set of command you must know to start playing with vimagit. See [Mappings](#mappings) for a complete description.

To simply test vimagit, modify/add/delete/rename some files in a git repository and open vim.

#### :Magit

Open magit buffer with [:Magit](#magitshow_magit) command.

#### N

* Jump to next hunk with **N**. The cursor should be on the header of a hunk.

#### S
- `:Magit`
Open magit buffer with [:Magit](#magitshow_magit) command.
- `N`
Jump to next hunk with `N`, or move the cursor as you like. The cursor is on a hunk.
- `S`
While the cursor is on an unstaged hunk, press `S` in Normal mode: the hunk is now staged, and appears in "Staged changes" section (you can also unstage a hunk from "Staged section" with `S`).
- `CC`
Once you have stage all the required changes, press `CC`.
- Section "Commit message" is shown.
- Type your commit message in this section.
- To commit, go back in Normal mode, and press `CC` (or `:w` if you prefer).

You just created your first commit with vimagit!

* If the hunk is in "Unstage changes" section, press **S** in Normal mode: the hunk is now staged, and appears in "Staged changes" section. The opposite is also possible, i.e. unstage a hunk from "Staged section".
* If you move the cursor to the file header and press **S**, the whole file is staged.

#### CC

Once you have stage all the required changes, type **CC**. A new section "Commit message" appears and cursor move to it. Type your commit message, in Insert mode this time. Once it's done, write your commit message with :w (or :x, :wq, ZZ).
## Installation

Voila! you created your first commit with vimagit!
This plugin follows the standard runtime path structure, and as such it can be installed with a variety of plugin managers:

- Pathogen
`git clone https://github.com/jreybert/vimagit ~/.vim/bundle/vimagit`
Remember to run :Helptags to generate help tags
- NeoBundle
`NeoBundle 'jreybert/vimagit'`
- Vundle
`Plugin 'jreybert/vimagit'`
- Plug
`Plug 'jreybert/vimagit'`
- VAM
`call vam#ActivateAddons([ 'jreybert/vimagit' ])`
- manual
copy all of the files into your ~/.vim directory

## Usage

Expand Down Expand Up @@ -226,6 +229,9 @@ E means 'edit'.
##### R
* Refresh magit buffer

##### -,+,0
* Shrink,enlarge,reset diff context

##### q
* Close the magit buffer

Expand Down Expand Up @@ -352,21 +358,31 @@ or a hunk is staged/unstaged).
Default value is 1.
> let g:magit_refresh_gitgutter=[01]
## Installation
## Requirements

The plugin hierarchy tree respects the vim plugin standard. It is compatible
with pathogen (and most probably vundle).
This part must be refined, I don't see any minimal version for git and vim, but for sure there should be one.

To install:
At least, it is tested with vim 7.3.249 and git 1.8.5.6 (see [Integration](#integration)).

cd ~/.vim/bundle
git clone https://github.com/jreybert/vimagit
## Integration

## Requirements
Branches [master](https://github.com/jreybert/vimagit/) and [next](https://github.com/jreybert/vimagit/tree/next) are continuously tested on [travis](https://travis-ci.org/jreybert/vimagit) when published on github.

This part must be refined, I don't see any minimal version for git and vim, but for sure there should be one.
vimagit is tested with various versions of vim on linux: vim 7.3.249, vim 7.4.273, and latest neovim version. It is also tested for macos X: vim, macvim and neovim. Anyway, if you feel that vimagit behaves oddly (slow refresh, weird display order...) please fill an [issue](https://github.com/jreybert/vimagit/issues/new).

At least, it is tested with vim 7.3.249 and git 1.8.5.6 (see [Integration](#integration)).
For the most enthusiastic, you can try the branch [next](https://github.com/jreybert/vimagit/tree/next). It is quite stable, just check its travis status before fetching it.

Travis status:
* **[master status](https://travis-ci.org/jreybert/vimagit/branches)**: [![Master build status](https://travis-ci.org/jreybert/vimagit.svg?branch=master)](https://travis-ci.org/jreybert/vimagit/branches)
* **[next status](https://travis-ci.org/jreybert/vimagit/branches)**: [![next build status](https://travis-ci.org/jreybert/vimagit.svg?branch=next)](https://travis-ci.org/jreybert/vimagit/branches)

A lot a features are developed in dev/feature_name branches. While it may be asked to users to test these branches (during a bug fix for example), one is warned that these branches may be heavily rebased/deleted.

## Contribution guideline

Pull requests are very welcomed. Some good practice:
- Make your pull request upon `next` branch
- In case changes are asked in your PR, prefer a rebase instead of a new commit

## Credits

Expand Down
4 changes: 2 additions & 2 deletions autoload/magit/git.vim
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ function! magit#git#git_diff(filename, status, mode)
let dev_null = ( a:status == '?' ) ? "/dev/null " : ""
let staged_flag = ( a:mode == 'staged' ) ? "--staged" : ""
let git_cmd=g:magit_git_cmd . " diff --no-ext-diff " . staged_flag .
\ " --no-color -p -- " . dev_null . " "
\ . a:filename
\ " --no-color -p -U" . b:magit_diff_context .
\ " -- " . dev_null . " " . a:filename
silent let diff_list=magit#utils#systemlist(git_cmd)
if ( a:status != '?' && v:shell_error != 0 )
echohl WarningMsg
Expand Down
8 changes: 8 additions & 0 deletions doc/vimagit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ Following mappings are set locally, for magit buffer only, in normal mode.

*vimagit-N* *magit#jump_hunk()*
*vimagit-P*
*vimagit-g:magit_jump_next_hunk*
*vimagit-g:magit_jump_prev_hunk*
N,P Move to Next or Previous hunk.

*vimagit-CC* *magit#commit_command('CC')*
Expand Down Expand Up @@ -267,6 +269,12 @@ Following mappings are set locally, for magit buffer only, in normal mode.
*vimagit-g:magit_reload_mapping*
R Refresh magit buffer.

*magit#update_diff()*
*vimagit--* *vimagit-g:magit_diff_shrink*
*vimagit-+* *vimagit-g:magit_diff_enlarge*
*vimagit-0* *vimagit-g:magit_diff_reset*
-,+,0 Shrink,enlarge,reset diff context

*vimagit-q*
*vimagit-g:magit_close_mapping*
q close magit buffer.
Expand Down
22 changes: 22 additions & 0 deletions plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ let g:magit_ignore_mapping = get(g:, 'magit_ignore_mapping',
let g:magit_close_mapping = get(g:, 'magit_close_mapping', 'q' )
let g:magit_toggle_help_mapping = get(g:, 'magit_toggle_help_mapping', '?' )

let g:magit_diff_shrink = get(g:, 'magit_diff_shrink', '-' )
let g:magit_diff_enlarge = get(g:, 'magit_diff_enlarge', '+' )
let g:magit_diff_reset = get(g:, 'magit_diff_reset', '0' )

let g:magit_folding_toggle_mapping = get(g:, 'magit_folding_toggle_mapping', [ '<CR>' ])
let g:magit_folding_open_mapping = get(g:, 'magit_folding_open_mapping', [ 'zo', 'zO' ])
let g:magit_folding_close_mapping = get(g:, 'magit_folding_close_mapping', [ 'zc', 'zC' ])
Expand Down Expand Up @@ -115,6 +119,8 @@ let s:magit_inline_help = {
\. ' commit undo, cancel and close current commit message',
\g:magit_reload_mapping
\.' refresh magit buffer',
\g:magit_diff_shrink.','.g:magit_diff_enlarge.','.g:magit_diff_reset
\. ' shrink,enlarge,reset diff context',
\g:magit_close_mapping
\.' close magit buffer',
\g:magit_toggle_help_mapping
Expand Down Expand Up @@ -832,6 +838,8 @@ function! magit#show_magit(display, ...)
let b:magit_current_commit_mode=''
let b:magit_commit_newly_open=0

let b:magit_diff_context=3

call magit#utils#setbufnr(bufnr(buffer_name))
call magit#sign#init()

Expand All @@ -846,6 +854,9 @@ function! magit#show_magit(display, ...)
execute "nnoremap <buffer> <silent> " . g:magit_close_commit_mapping . " :call magit#close_commit()<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_ignore_mapping . " :call magit#ignore_file()<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_close_mapping . " :call magit#close_magit()<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_diff_shrink . " :call magit#update_diff('-')<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_diff_enlarge . " :call magit#update_diff('+')<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_diff_reset . " :call magit#update_diff('0')<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_toggle_help_mapping . " :call magit#toggle_help()<cr>"

execute "nnoremap <buffer> <silent> " . g:magit_stage_line_mapping . " :call magit#stage_vselect()<cr>"
Expand Down Expand Up @@ -1221,6 +1232,17 @@ function! magit#jump_to()
execute "edit " . "+" . line . " " filename
endfunction

function! magit#update_diff(way)
if ( a:way == "+" )
let b:magit_diff_context+=1
elseif ( a:way == "0" )
let b:magit_diff_context=3
elseif ( b:magit_diff_context > 1 )
let b:magit_diff_context-=1
endif
call magit#update_buffer()
endfunction

function! magit#show_version()
return g:vimagit_version[0] . "." .
\ g:vimagit_version[1] . "." .
Expand Down

0 comments on commit 4b53e6a

Please sign in to comment.