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

Update git layer (#2761)

* Update git layer

* Disable signify when git layer is loaded

* Add key binding

* Update key binding

* Update doc
This commit is contained in:
Wang Shidong 2019-04-24 21:13:20 +08:00 committed by GitHub
parent 37e92abe67
commit b627d2e8ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 12 deletions

View File

@ -14,7 +14,9 @@ let s:enable_gtm_status = 0
function! SpaceVim#layers#VersionControl#plugins() abort
let plugins = []
if !SpaceVim#layers#isLoaded('git')
call add(plugins, ['mhinz/vim-signify', {'merged' : 0, 'loadconf' : 1}])
endif
return plugins
endfunction
@ -103,10 +105,15 @@ function! s:gtm_statusline() abort
endfunction
" +0 ~0 -0
" if git layser is loaded, use vim-gitgutter instead.
function! s:hunks() abort
let hunks = [0,0,0]
try
if SpaceVim#layers#isLoaded('git')
let hunks = GitGutterGetHunkSummary()
else
let hunks = sy#repo#get_stats()
endif
catch
endtry
let rst = ''

View File

@ -24,6 +24,7 @@ function! SpaceVim#layers#git#plugins() abort
\ ['junegunn/gv.vim', { 'on_cmd' : ['GV']}],
\ ]
call add(plugins, ['tpope/vim-fugitive', { 'merged' : 0}])
call add(plugins, ['airblade/vim-gitgutter', { 'merged' : 0}])
if s:git_plugin ==# 'gina'
call add(plugins, ['lambdalisue/gina.vim', { 'on_cmd' : 'Gina'}])
elseif s:git_plugin ==# 'fugitive'
@ -39,6 +40,7 @@ endfunction
function! SpaceVim#layers#git#config() abort
let g:signify_vcs_list = ['hg']
let g:_spacevim_mappings_space.g = get(g:_spacevim_mappings_space, 'g', {'name' : '+VersionControl/git'})
if s:git_plugin ==# 'gina'
call SpaceVim#mapping#space#def('nnoremap', ['g', 's'], 'Gina status --opener=10split', 'git status', 1)
@ -82,6 +84,10 @@ function! SpaceVim#layers#git#config() abort
\ 'display the last commit message of the current line', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'V'], 'GV!', 'View git log of current file', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'v'], 'GV', 'View git log of current repo', 1)
let g:_spacevim_mappings_space.g.h = {'name' : '+Hunks'}
call SpaceVim#mapping#space#def('nmap', ['g', 'h', 'a'], '<Plug>GitGutterStageHunk', 'stage current hunk', 0)
call SpaceVim#mapping#space#def('nmap', ['g', 'h', 'r'], '<Plug>GitGutterUndoHunk', 'undo cursor hunk', 0)
call SpaceVim#mapping#space#def('nmap', ['g', 'h', 'v'], '<Plug>GitGutterPreviewHunk', 'preview cursor hunk', 0)
endfunction
function! SpaceVim#layers#git#set_variable(var) abort

View File

@ -30,7 +30,7 @@ lang: cn
## 快捷键
| 快捷键 | 功能描述 |
| --------- | -------------------- |
| ----------- | -------------------- |
| `SPC g s` | 打开 git status 窗口 |
| `SPC g S` | stage 当前文件 |
| `SPC g U` | unstage 当前文件 |
@ -39,3 +39,6 @@ lang: cn
| `SPC g d` | 打开 git diff 窗口 |
| `SPC g A` | git add 所有文件 |
| `SPC g b` | 打开 git blame 窗口 |
| `SPC g h a` | stage current hunk |
| `SPC g h r` | undo cursor hunk |
| `SPC g h v` | preview cursor hunk |

View File

@ -38,3 +38,6 @@ To use this configuration layer, add following snippet to your custom configurat
| `SPC g d` | view git diff |
| `SPC g A` | stage all files |
| `SPC g b` | open git blame windows |
| `SPC g h a` | stage current hunk |
| `SPC g h r` | undo cursor hunk |
| `SPC g h v` | preview cursor hunk |