mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-23 17:49:57 +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
|
function! SpaceVim#layers#VersionControl#plugins() abort
|
||||||
let plugins = []
|
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
|
return plugins
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -103,10 +105,15 @@ function! s:gtm_statusline() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" +0 ~0 -0
|
" +0 ~0 -0
|
||||||
|
" if git layser is loaded, use vim-gitgutter instead.
|
||||||
function! s:hunks() abort
|
function! s:hunks() abort
|
||||||
let hunks = [0,0,0]
|
let hunks = [0,0,0]
|
||||||
try
|
try
|
||||||
let hunks = sy#repo#get_stats()
|
if SpaceVim#layers#isLoaded('git')
|
||||||
|
let hunks = GitGutterGetHunkSummary()
|
||||||
|
else
|
||||||
|
let hunks = sy#repo#get_stats()
|
||||||
|
endif
|
||||||
catch
|
catch
|
||||||
endtry
|
endtry
|
||||||
let rst = ''
|
let rst = ''
|
||||||
|
@ -24,6 +24,7 @@ function! SpaceVim#layers#git#plugins() abort
|
|||||||
\ ['junegunn/gv.vim', { 'on_cmd' : ['GV']}],
|
\ ['junegunn/gv.vim', { 'on_cmd' : ['GV']}],
|
||||||
\ ]
|
\ ]
|
||||||
call add(plugins, ['tpope/vim-fugitive', { 'merged' : 0}])
|
call add(plugins, ['tpope/vim-fugitive', { 'merged' : 0}])
|
||||||
|
call add(plugins, ['airblade/vim-gitgutter', { 'merged' : 0}])
|
||||||
if s:git_plugin ==# 'gina'
|
if s:git_plugin ==# 'gina'
|
||||||
call add(plugins, ['lambdalisue/gina.vim', { 'on_cmd' : 'Gina'}])
|
call add(plugins, ['lambdalisue/gina.vim', { 'on_cmd' : 'Gina'}])
|
||||||
elseif s:git_plugin ==# 'fugitive'
|
elseif s:git_plugin ==# 'fugitive'
|
||||||
@ -39,6 +40,7 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! SpaceVim#layers#git#config() abort
|
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'})
|
let g:_spacevim_mappings_space.g = get(g:_spacevim_mappings_space, 'g', {'name' : '+VersionControl/git'})
|
||||||
if s:git_plugin ==# 'gina'
|
if s:git_plugin ==# 'gina'
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['g', 's'], 'Gina status --opener=10split', 'git status', 1)
|
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)
|
\ '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 file', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['g', 'v'], 'GV', 'View git log of current repo', 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
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#layers#git#set_variable(var) abort
|
function! SpaceVim#layers#git#set_variable(var) abort
|
||||||
|
@ -29,13 +29,16 @@ lang: cn
|
|||||||
|
|
||||||
## 快捷键
|
## 快捷键
|
||||||
|
|
||||||
| 快捷键 | 功能描述 |
|
| 快捷键 | 功能描述 |
|
||||||
| --------- | -------------------- |
|
| ----------- | -------------------- |
|
||||||
| `SPC g s` | 打开 git status 窗口 |
|
| `SPC g s` | 打开 git status 窗口 |
|
||||||
| `SPC g S` | stage 当前文件 |
|
| `SPC g S` | stage 当前文件 |
|
||||||
| `SPC g U` | unstage 当前文件 |
|
| `SPC g U` | unstage 当前文件 |
|
||||||
| `SPC g c` | 打开 git commit 窗口 |
|
| `SPC g c` | 打开 git commit 窗口 |
|
||||||
| `SPC g p` | 执行 git push |
|
| `SPC g p` | 执行 git push |
|
||||||
| `SPC g d` | 打开 git diff 窗口 |
|
| `SPC g d` | 打开 git diff 窗口 |
|
||||||
| `SPC g A` | git add 所有文件 |
|
| `SPC g A` | git add 所有文件 |
|
||||||
| `SPC g b` | 打开 git blame 窗口 |
|
| `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 d` | view git diff |
|
||||||
| `SPC g A` | stage all files |
|
| `SPC g A` | stage all files |
|
||||||
| `SPC g b` | open git blame windows |
|
| `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…
x
Reference in New Issue
Block a user