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

Add git plugin (#3244)

This commit is contained in:
Wang Shidong 2019-12-07 16:04:55 +08:00 committed by GitHub
parent 2324c37b7a
commit 24da07159a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 26 deletions

View File

@ -386,6 +386,15 @@ function! SpaceVim#layers#core#statusline#get(...) abort
let st .= '%#SpaceVim_statusline_c# %{b:_spacevim_shell} %#SpaceVim_statusline_c_SpaceVim_statusline_z#' . s:lsep
endif
return st
elseif &filetype ==# 'git-status'
return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep
\ . '%#SpaceVim_statusline_b# Git status %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep . ' '
elseif &filetype ==# 'git-commit'
return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep
\ . '%#SpaceVim_statusline_b# Git commit %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep . ' '
elseif &filetype ==# 'git-diff'
return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep
\ . '%#SpaceVim_statusline_b# Git diff %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep . ' '
elseif &filetype ==# 'gina-status'
return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep
\ . '%#SpaceVim_statusline_b# Gina status %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep . ' '

View File

@ -11,11 +11,7 @@
" 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
let s:git_plugin = 'git'
@ -23,14 +19,16 @@ function! SpaceVim#layers#git#plugins() abort
let plugins = [
\ ['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'
call add(plugins, ['tpope/vim-fugitive', { 'merged' : 0}])
call add(plugins, ['tpope/vim-dispatch', { 'merged' : 0}])
else
elseif s:git_plugin ==# 'gita'
call add(plugins, ['lambdalisue/vim-gita', { 'on_cmd' : 'Gita'}])
else
call add(plugins, ['wsdjeg/git.vim', { 'on_cmd' : 'Git'}])
endif
if g:spacevim_filemanager ==# 'nerdtree'
call add(plugins, ['Xuyuanp/nerdtree-git-plugin', {'merged' : 0}])
@ -60,7 +58,8 @@ function! SpaceVim#layers#git#config() abort
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'], 'Gblame', 'view-git-blame', 1)
else
elseif s:git_plugin ==# 'gita'
let g:gita#suppress_warning = 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', 'U'], 'Gita reset %', 'unstage-current-file', 1)
@ -69,6 +68,15 @@ function! SpaceVim#layers#git#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['g', 'd'], 'Gita diff', 'view-git-diff', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'A'], 'Gita add .', 'stage-all-files', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'b'], 'Gina blame', 'view-git-blame', 1)
else
call SpaceVim#mapping#space#def('nnoremap', ['g', 's'], 'Git status', '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 %', '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'], 'Git push', 'git-push', 1)
call SpaceVim#mapping#space#def('nnoremap', ['g', 'd'], 'Git diff', '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)
endif
augroup spacevim_layer_git
autocmd!

View File

@ -9,11 +9,31 @@
""
" @section lang#elm, layer-lang-elm
" @parentsection layers
" @subsection Intro
" The lang#elm layer provides code completion, documentation lookup, jump to
" definition, mix integration, and iex integration for elm. SpaceVim
" uses neomake as default syntax checker which is loaded in
" @section(layer-checkers)
" This layer is for elm development, disabled by default, to enable this
" layer, add following snippet to your SpaceVim configuration file.
" >
" [[layers]]
" name = 'lang#elm'
" <
"
" @subsection Key bindings
" >
" Mode Key Function
" ---------------------------------------------
" normal SPC l r run current file
" <
"
" This layer also provides REPL support for elm, the key bindings are:
" >
" Key Function
" ---------------------------------------------
" SPC l s i Start a inferior REPL process
" SPC l s b send whole buffer
" SPC l s l send current line
" SPC l s s send selection text
" <
"
function! SpaceVim#layers#lang#elm#plugins() abort
let plugins = []
@ -24,10 +44,12 @@ endfunction
function! SpaceVim#layers#lang#elm#config() abort
call SpaceVim#plugins#repl#reg('elm', 'elm repl')
call SpaceVim#plugins#runner#reg_runner('elm', 'elm %s')
call SpaceVim#mapping#space#regesit_lang_mappings('elm', function('s:language_specified_mappings'))
endfunction
function! s:language_specified_mappings() abort
call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1)
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
\ 'call SpaceVim#plugins#repl#start("elm")',

View File

@ -1583,10 +1583,31 @@ This layer also provides REPL support for d, the key bindings are:
==============================================================================
LANG#ELM *SpaceVim-layer-lang-elm*
INTRO
The lang#elm layer provides code completion, documentation lookup, jump to
definition, mix integration, and iex integration for elm. SpaceVim uses
neomake as default syntax checker which is loaded in |SpaceVim-layer-checkers|
This layer is for elm development, disabled by default, to enable this layer,
add following snippet to your SpaceVim configuration file.
>
[[layers]]
name = 'lang#elm'
<
KEY BINDINGS
>
Mode Key Function
---------------------------------------------
normal SPC l r run current file
<
This layer also provides REPL support for elm, the key bindings are:
>
Key Function
---------------------------------------------
SPC l s i Start a inferior REPL process
SPC l s b send whole buffer
SPC l s l send current line
SPC l s s send selection text
<
==============================================================================
LANG#ERLANG *SpaceVim-layer-lang-erlang*