1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 02:30:03 +08:00

Add layer option for git layer (#2583)

* Add layer option for git layer

* Change git diff command

* Change git push

* Add vim-dispatch
This commit is contained in:
Wang Shidong 2019-04-13 16:31:16 +08:00 committed by GitHub
parent e55f041ad3
commit 0a2be9fb93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,13 +6,28 @@
" License: GPLv3
"=============================================================================
" Layer Options:
" s:git_plugin which plugin is used as the background plugin in git layer
if has('patch-8.0.0027') || has('nvim')
let s:git_plugin = 'gina'
else
let s:git_plugin = 'gita'
endif
function! SpaceVim#layers#git#plugins() abort
let plugins = [
\ ['junegunn/gv.vim', { 'on_cmd' : ['GV']}],
\ ]
call add(plugins, ['tpope/vim-fugitive', { 'merged' : 0}])
if has('patch-8.0.0027') || has('nvim')
if s:git_plugin ==# 'gina'
call add(plugins, ['lambdalisue/gina.vim', { 'on_cmd' : 'Gina'}])
elseif s:git_plugin ==# 'fugitive'
call add(plugins, ['tpope/vim-dispatch', { 'merged' : 0}])
else
call add(plugins, ['lambdalisue/vim-gita', { 'on_cmd' : 'Gita'}])
endif
@ -25,7 +40,7 @@ endfunction
function! SpaceVim#layers#git#config() abort
let g:_spacevim_mappings_space.g = get(g:_spacevim_mappings_space, 'g', {'name' : '+VersionControl/git'})
if has('patch-8.0.0027') || has('nvim')
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 add %', 'stage current file', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'U'], 'Gina reset -q %', 'unstage current file', 1)
@ -34,6 +49,15 @@ function! SpaceVim#layers#git#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['g', 'd'], 'Gina diff', 'view git diff', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'A'], 'Gina add .', 'stage all files', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'b'], 'Gina blame', 'view git blame', 1)
elseif s:git_plugin ==# 'fugitive'
call SpaceVim#mapping#space#def('nnoremap', ['g', 's'], 'Gstatus', 'git status', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'S'], 'Git add %', 'stage current file', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'U'], 'Git reset -q %', 'unstage current file', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'c'], 'Git commit', 'edit git commit', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'p'], 'Gpush', 'git push', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'd'], 'Gdiff', 'view git diff', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'A'], 'Git add .', 'stage all files', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'b'], 'Git blame', 'view git blame', 1)
else
call SpaceVim#mapping#space#def('nnoremap', ['g', 's'], 'Gita status', 'git status', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'S'], 'Gita add %', 'stage current file', 1)
@ -60,6 +84,14 @@ function! SpaceVim#layers#git#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['g', 'v'], 'GV', 'View git log of current repo', 1)
endfunction
function! SpaceVim#layers#git#set_variable(var) abort
let s:git_plugin = get(a:var,
\ 'git-plugin',
\ s:git_plugin)
endfunction
function! s:display_last_commit_of_current_line() abort
let line = line('.')
let file = expand('%')