mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 12:50: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:
parent
37e92abe67
commit
b627d2e8ab
@ -14,7 +14,9 @@ let s:enable_gtm_status = 0
|
||||
|
||||
function! SpaceVim#layers#VersionControl#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, ['mhinz/vim-signify', {'merged' : 0, 'loadconf' : 1}])
|
||||
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
|
||||
let hunks = sy#repo#get_stats()
|
||||
if SpaceVim#layers#isLoaded('git')
|
||||
let hunks = GitGutterGetHunkSummary()
|
||||
else
|
||||
let hunks = sy#repo#get_stats()
|
||||
endif
|
||||
catch
|
||||
endtry
|
||||
let rst = ''
|
||||
|
@ -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
|
||||
|
@ -29,13 +29,16 @@ lang: cn
|
||||
|
||||
## 快捷键
|
||||
|
||||
| 快捷键 | 功能描述 |
|
||||
| --------- | -------------------- |
|
||||
| `SPC g s` | 打开 git status 窗口 |
|
||||
| `SPC g S` | stage 当前文件 |
|
||||
| `SPC g U` | unstage 当前文件 |
|
||||
| `SPC g c` | 打开 git commit 窗口 |
|
||||
| `SPC g p` | 执行 git push |
|
||||
| `SPC g d` | 打开 git diff 窗口 |
|
||||
| `SPC g A` | git add 所有文件 |
|
||||
| `SPC g b` | 打开 git blame 窗口 |
|
||||
| 快捷键 | 功能描述 |
|
||||
| ----------- | -------------------- |
|
||||
| `SPC g s` | 打开 git status 窗口 |
|
||||
| `SPC g S` | stage 当前文件 |
|
||||
| `SPC g U` | unstage 当前文件 |
|
||||
| `SPC g c` | 打开 git commit 窗口 |
|
||||
| `SPC g p` | 执行 git push |
|
||||
| `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 |
|
||||
|
@ -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 |
|
||||
|
Loading…
Reference in New Issue
Block a user