mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-09 12:30:05 +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:
parent
e55f041ad3
commit
0a2be9fb93
@ -6,13 +6,28 @@
|
|||||||
" License: GPLv3
|
" 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
|
function! SpaceVim#layers#git#plugins() abort
|
||||||
let plugins = [
|
let plugins = [
|
||||||
\ ['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}])
|
||||||
if has('patch-8.0.0027') || has('nvim')
|
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'
|
||||||
|
call add(plugins, ['tpope/vim-dispatch', { 'merged' : 0}])
|
||||||
else
|
else
|
||||||
call add(plugins, ['lambdalisue/vim-gita', { 'on_cmd' : 'Gita'}])
|
call add(plugins, ['lambdalisue/vim-gita', { 'on_cmd' : 'Gita'}])
|
||||||
endif
|
endif
|
||||||
@ -25,7 +40,7 @@ endfunction
|
|||||||
|
|
||||||
function! SpaceVim#layers#git#config() abort
|
function! SpaceVim#layers#git#config() abort
|
||||||
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 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 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', 'S'], 'Gina add %', 'stage current file', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['g', 'U'], 'Gina reset -q %', 'unstage 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', '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', 'A'], 'Gina add .', 'stage all files', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['g', 'b'], 'Gina blame', 'view git blame', 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
|
else
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['g', 's'], 'Gita status', 'git status', 1)
|
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)
|
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)
|
call SpaceVim#mapping#space#def('nnoremap', ['g', 'v'], 'GV', 'View git log of current repo', 1)
|
||||||
endfunction
|
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
|
function! s:display_last_commit_of_current_line() abort
|
||||||
let line = line('.')
|
let line = line('.')
|
||||||
let file = expand('%')
|
let file = expand('%')
|
||||||
|
Loading…
Reference in New Issue
Block a user