1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 13:40:05 +08:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Eric Wong
0801126d19 feat(git): complete checkout command 2024-12-09 22:29:20 +08:00
Eric Wong
a50c6bf250 ci(detach): fix detach script 2024-12-09 21:27:41 +08:00
Eric Wong
a42b6b39bc docs(git): update readme of git.vim 2024-12-09 20:59:42 +08:00
Eric Wong
859e2db582 fix(guide): update language specified mapping
close https://github.com/SpaceVim/SpaceVim/issues/4942
2024-12-09 20:46:30 +08:00
6 changed files with 212 additions and 159 deletions

View File

@ -4,7 +4,7 @@ _detact () {
cp -f ../../$1 $1 cp -f ../../$1 $1
} }
_detact_bundle () { _detach_bundle () {
cp -f ../../bundle/$1/$2 $2 cp -f ../../bundle/$1/$2 $2
} }
@ -86,16 +86,16 @@ main () {
_detact syntax/SpaceVimFlyGrep.vim _detact syntax/SpaceVimFlyGrep.vim
# detach bundle # detach bundle
_checkdir plugin _checkdir plugin
_detact_bundle FlyGrep plugin/FlyGrep.vim _detach_bundle FlyGrep plugin/FlyGrep.vim
_detact_bundle FlyGrep README.md _detach_bundle FlyGrep README.md
_detact_bundle FlyGrep addon-info.json _detach_bundle FlyGrep addon-info.json
_checkdir doc/ _checkdir doc/
_detact_bundle FlyGrep doc/FlyGrep.txt _detach_bundle FlyGrep doc/FlyGrep.txt
# detach LICENSE # detach LICENSE
_detact LICENSE _detact LICENSE
# detach test vimrc # detach test vimrc
_checkdir test _checkdir test
_detact_bundle FlyGrep test/vimrc _detach_bundle FlyGrep test/vimrc
;; ;;
dein-ui.vim) dein-ui.vim)
git clone https://github.com/wsdjeg/dein-ui.vim.git detach/$1 git clone https://github.com/wsdjeg/dein-ui.vim.git detach/$1
@ -121,23 +121,23 @@ main () {
git clone https://github.com/wsdjeg/cpicker.nvim.git detach/$1 git clone https://github.com/wsdjeg/cpicker.nvim.git detach/$1
cd detach/$1 cd detach/$1
_checkdir syntax _checkdir syntax
_detact_bundle cpicker.nvim syntax/spacevim_cpicker.vim _detach_bundle cpicker.nvim syntax/spacevim_cpicker.vim
_detact_bundle cpicker.nvim syntax/spacevim_cpicker_mix.vim _detach_bundle cpicker.nvim syntax/spacevim_cpicker_mix.vim
_detact_bundle cpicker.nvim README.md _detach_bundle cpicker.nvim README.md
_checkdir plugin _checkdir plugin
_detact_bundle cpicker.nvim plugin/cpicker.lua _detach_bundle cpicker.nvim plugin/cpicker.lua
_checkdir lua/cpicker/formats _checkdir lua/cpicker/formats
_detact_bundle cpicker.nvim lua/cpicker.lua _detach_bundle cpicker.nvim lua/cpicker.lua
_detact_bundle cpicker.nvim lua/cpicker/util.lua _detach_bundle cpicker.nvim lua/cpicker/util.lua
_detact_bundle cpicker.nvim lua/cpicker/mix.lua _detach_bundle cpicker.nvim lua/cpicker/mix.lua
_detact_bundle cpicker.nvim lua/cpicker/formats/cmyk.lua _detach_bundle cpicker.nvim lua/cpicker/formats/cmyk.lua
_detact_bundle cpicker.nvim lua/cpicker/formats/hsl.lua _detach_bundle cpicker.nvim lua/cpicker/formats/hsl.lua
_detact_bundle cpicker.nvim lua/cpicker/formats/hsv.lua _detach_bundle cpicker.nvim lua/cpicker/formats/hsv.lua
_detact_bundle cpicker.nvim lua/cpicker/formats/hwb.lua _detach_bundle cpicker.nvim lua/cpicker/formats/hwb.lua
_detact_bundle cpicker.nvim lua/cpicker/formats/lab.lua _detach_bundle cpicker.nvim lua/cpicker/formats/lab.lua
_detact_bundle cpicker.nvim lua/cpicker/formats/linear.lua _detach_bundle cpicker.nvim lua/cpicker/formats/linear.lua
_detact_bundle cpicker.nvim lua/cpicker/formats/rgb.lua _detach_bundle cpicker.nvim lua/cpicker/formats/rgb.lua
_detact_bundle cpicker.nvim lua/cpicker/formats/xyz.lua _detach_bundle cpicker.nvim lua/cpicker/formats/xyz.lua
_checkdir lua/spacevim/api _checkdir lua/spacevim/api
_detact lua/spacevim/api/color.lua _detact lua/spacevim/api/color.lua
_detact lua/spacevim/api/notify.lua _detact lua/spacevim/api/notify.lua
@ -157,16 +157,16 @@ main () {
git clone https://github.com/wsdjeg/SourceCounter.vim.git detach/$1 git clone https://github.com/wsdjeg/SourceCounter.vim.git detach/$1
cd detach/$1 cd detach/$1
_checkdir plugin _checkdir plugin
_detact_bundle SourceCounter.vim plugin/SourceCounter.vim _detach_bundle SourceCounter.vim plugin/SourceCounter.vim
_checkdir autoload _checkdir autoload
_detact_bundle SourceCounter.vim autoload/SourceCounter.vim _detach_bundle SourceCounter.vim autoload/SourceCounter.vim
_checkdir doc _checkdir doc
_detact_bundle SourceCounter.vim doc/SourceCounter.vim.txt _detach_bundle SourceCounter.vim doc/SourceCounter.vim.txt
_detact_bundle SourceCounter.vim README.md _detach_bundle SourceCounter.vim README.md
_detact_bundle SourceCounter.vim addon-info.json _detach_bundle SourceCounter.vim addon-info.json
_detact LICENSE _detact LICENSE
_checkdir pic _checkdir pic
_detact_bundle SourceCounter.vim pic/screen.png _detach_bundle SourceCounter.vim pic/screen.png
_checkdir autoload/SpaceVim/api/vim _checkdir autoload/SpaceVim/api/vim
_checkdir autoload/SpaceVim/api/data _checkdir autoload/SpaceVim/api/data
_detact autoload/SpaceVim/api/notify.vim _detact autoload/SpaceVim/api/notify.vim
@ -255,18 +255,18 @@ EOT
_detact autoload/SpaceVim/api.vim _detact autoload/SpaceVim/api.vim
_detact autoload/SpaceVim/api/job.vim _detact autoload/SpaceVim/api/job.vim
_checkdir autoload/chat/ _checkdir autoload/chat/
_detact_bundle vim-chat autoload/chat.vim _detach_bundle vim-chat autoload/chat.vim
_detact_bundle vim-chat autoload/chat/gitter.vim _detach_bundle vim-chat autoload/chat/gitter.vim
_detact_bundle vim-chat autoload/chat/logger.vim _detach_bundle vim-chat autoload/chat/logger.vim
_detact_bundle vim-chat autoload/chat/notify.vim _detach_bundle vim-chat autoload/chat/notify.vim
_detact_bundle vim-chat autoload/chat/qq.vim _detach_bundle vim-chat autoload/chat/qq.vim
_detact_bundle vim-chat autoload/chat/weixin.vim _detach_bundle vim-chat autoload/chat/weixin.vim
_checkdir doc/ _checkdir doc/
_detact_bundle vim-chat doc/vim-chat.txt _detach_bundle vim-chat doc/vim-chat.txt
_checkdir syntax/ _checkdir syntax/
_detact_bundle vim-chat syntax/vimchat.vim _detach_bundle vim-chat syntax/vimchat.vim
_detact_bundle vim-chat addon-info.json _detach_bundle vim-chat addon-info.json
_detact_bundle vim-chat README.md _detach_bundle vim-chat README.md
;; ;;
JavaUnit.vim) JavaUnit.vim)
git clone https://github.com/wsdjeg/JavaUnit.vim.git detach/$1 git clone https://github.com/wsdjeg/JavaUnit.vim.git detach/$1
@ -276,7 +276,7 @@ EOT
# _detact autoload/SpaceVim/api.vim # _detact autoload/SpaceVim/api.vim
# _detact autoload/SpaceVim/api/job.vim # _detact autoload/SpaceVim/api/job.vim
# _checkdir autoload/chat/ # _checkdir autoload/chat/
_detact_bundle JavaUnit.vim README.md _detach_bundle JavaUnit.vim README.md
;; ;;
git.vim) git.vim)
git clone https://github.com/wsdjeg/git.vim.git detach/$1 git clone https://github.com/wsdjeg/git.vim.git detach/$1
@ -284,48 +284,48 @@ EOT
_checkdir autoload/SpaceVim/api _checkdir autoload/SpaceVim/api
_detact autoload/SpaceVim/api.vim _detact autoload/SpaceVim/api.vim
_detact autoload/SpaceVim/api/job.vim _detact autoload/SpaceVim/api/job.vim
_detact_bundle git.vim LICENSE _detach_bundle git.vim LICENSE
_detact_bundle git.vim README.md _detach_bundle git.vim README.md
_detact_bundle git.vim addon-info.json _detach_bundle git.vim addon-info.json
_checkdir autoload/git/branch _checkdir autoload/git/branch
_detact_bundle git.vim autoload/git.vim _detach_bundle git.vim autoload/git.vim
_detact_bundle git.vim autoload/git/add.vim _detach_bundle git.vim autoload/git/add.vim
_detact_bundle git.vim autoload/git/blame.vim _detach_bundle git.vim autoload/git/blame.vim
_detact_bundle git.vim autoload/git/branch.vim _detach_bundle git.vim autoload/git/branch.vim
_detact_bundle git.vim autoload/git/branch/manager.vim _detach_bundle git.vim autoload/git/branch/manager.vim
_detact_bundle git.vim autoload/git/checkout.vim _detach_bundle git.vim autoload/git/checkout.vim
_detact_bundle git.vim autoload/git/cherry_pick.vim _detach_bundle git.vim autoload/git/cherry_pick.vim
_detact_bundle git.vim autoload/git/clean.vim _detach_bundle git.vim autoload/git/clean.vim
_detact_bundle git.vim autoload/git/commit.vim _detach_bundle git.vim autoload/git/commit.vim
_detact_bundle git.vim autoload/git/config.vim _detach_bundle git.vim autoload/git/config.vim
_detact_bundle git.vim autoload/git/diff.vim _detach_bundle git.vim autoload/git/diff.vim
_detact_bundle git.vim autoload/git/fetch.vim _detach_bundle git.vim autoload/git/fetch.vim
_detact_bundle git.vim autoload/git/log.vim _detach_bundle git.vim autoload/git/log.vim
_detact_bundle git.vim autoload/git/logger.vim _detach_bundle git.vim autoload/git/logger.vim
_detact_bundle git.vim autoload/git/merge.vim _detach_bundle git.vim autoload/git/merge.vim
_detact_bundle git.vim autoload/git/mv.vim _detach_bundle git.vim autoload/git/mv.vim
_detact_bundle git.vim autoload/git/pull.vim _detach_bundle git.vim autoload/git/pull.vim
_detact_bundle git.vim autoload/git/push.vim _detach_bundle git.vim autoload/git/push.vim
_detact_bundle git.vim autoload/git/rebase.vim _detach_bundle git.vim autoload/git/rebase.vim
_detact_bundle git.vim autoload/git/reflog.vim _detach_bundle git.vim autoload/git/reflog.vim
_detact_bundle git.vim autoload/git/remote.vim _detach_bundle git.vim autoload/git/remote.vim
_detact_bundle git.vim autoload/git/reset.vim _detach_bundle git.vim autoload/git/reset.vim
_detact_bundle git.vim autoload/git/rm.vim _detach_bundle git.vim autoload/git/rm.vim
_detact_bundle git.vim autoload/git/stash.vim _detach_bundle git.vim autoload/git/stash.vim
_detact_bundle git.vim autoload/git/status.vim _detach_bundle git.vim autoload/git/status.vim
_checkdir doc _checkdir doc
_detact_bundle git.vim doc/git.txt _detach_bundle git.vim doc/git.txt
_checkdir plugin _checkdir plugin
_detact_bundle git.vim plugin/git.vim _detach_bundle git.vim plugin/git.vim
_checkdir syntax _checkdir syntax
_detact_bundle git.vim syntax/git-blame.vim _detach_bundle git.vim syntax/git-blame.vim
_detact_bundle git.vim syntax/git-commit.vim _detach_bundle git.vim syntax/git-commit.vim
_detact_bundle git.vim syntax/git-config.vim _detach_bundle git.vim syntax/git-config.vim
_detact_bundle git.vim syntax/git-log.vim _detach_bundle git.vim syntax/git-log.vim
_detact_bundle git.vim syntax/git-rebase.vim _detach_bundle git.vim syntax/git-rebase.vim
_detact_bundle git.vim syntax/git-reflog.vim _detach_bundle git.vim syntax/git-reflog.vim
_checkdir test _checkdir test
_detact_bundle git.vim test/vimrc _detach_bundle git.vim test/vimrc
_checkdir lua/spacevim/api _checkdir lua/spacevim/api
_detact lua/spacevim/api/job.lua _detact lua/spacevim/api/job.lua
_detact lua/spacevim/api/logger.lua _detact lua/spacevim/api/logger.lua
@ -336,9 +336,9 @@ EOT
_detact lua/spacevim/api/password.lua _detact lua/spacevim/api/password.lua
_checkdir lua/git/command _checkdir lua/git/command
_checkdir lua/git/ui _checkdir lua/git/ui
_detact_bundle git.vim lua/git/init.lua _detach_bundle git.vim lua/git/init.lua
_detact_bundle git.vim lua/git/log.lua _detach_bundle git.vim lua/git/log.lua
_detact_bundle git.vim lua/git/command/add.lua _detach_bundle git.vim lua/git/command/add.lua
_detach_bundle git.vim lua/git/command/add.lua _detach_bundle git.vim lua/git/command/add.lua
_detach_bundle git.vim lua/git/command/blame.lua _detach_bundle git.vim lua/git/command/blame.lua
_detach_bundle git.vim lua/git/command/branch.lua _detach_bundle git.vim lua/git/command/branch.lua
@ -374,55 +374,55 @@ EOT
_checkdir plugin/ _checkdir plugin/
_checkdir autoload/ _checkdir autoload/
_detact LICENSE _detact LICENSE
_detact_bundle vim-cheat autoload/cheat.vim _detach_bundle vim-cheat autoload/cheat.vim
_detact_bundle vim-cheat plugin/cheat.vim _detach_bundle vim-cheat plugin/cheat.vim
_detact_bundle vim-cheat README.md _detach_bundle vim-cheat README.md
_detact_bundle vim-cheat .travis.yml _detach_bundle vim-cheat .travis.yml
_detact_bundle vim-cheat .vintrc.yaml _detach_bundle vim-cheat .vintrc.yaml
_checkdir doc/ _checkdir doc/
_detact_bundle vim-cheat doc/vim-cheat.txt _detach_bundle vim-cheat doc/vim-cheat.txt
;; ;;
xmake.vim) xmake.vim)
git clone https://github.com/wsdjeg/xmake.vim.git detach/$1 git clone https://github.com/wsdjeg/xmake.vim.git detach/$1
cd detach/$1 cd detach/$1
_checkdir plugin/ _checkdir plugin/
_detact_bundle xmake.vim plugin/xmake.vim _detach_bundle xmake.vim plugin/xmake.vim
_detact_bundle xmake.vim plugin/xmgen.py _detach_bundle xmake.vim plugin/xmgen.py
_checkdir autoload/ _checkdir autoload/
_detact_bundle xmake.vim autoload/xmake.vim _detach_bundle xmake.vim autoload/xmake.vim
_detact_bundle xmake.vim autoload/spy.lua _detach_bundle xmake.vim autoload/spy.lua
_detact LICENSE _detact LICENSE
_default_readme "xmake.vim" "xmake support for neovim/vim" _default_readme "xmake.vim" "xmake support for neovim/vim"
_checkdir autoload/xmake/ _checkdir autoload/xmake/
_detact_bundle xmake.vim autoload/xmake/log.vim _detach_bundle xmake.vim autoload/xmake/log.vim
_checkdir doc/ _checkdir doc/
_detact_bundle xmake.vim doc/xmake.txt _detach_bundle xmake.vim doc/xmake.txt
_checkdir UltiSnips/ _checkdir UltiSnips/
_detact_bundle xmake.vim UltiSnips/lua.snippets _detach_bundle xmake.vim UltiSnips/lua.snippets
_checkdir rplugin/python3/deoplete/sources/docs/ _checkdir rplugin/python3/deoplete/sources/docs/
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/xmake.py _detach_bundle xmake.vim rplugin/python3/deoplete/sources/xmake.py
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_defines _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_defines
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_defines _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_defines
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_deps _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_deps
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_files _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_files
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_headers _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_headers
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_includedirs _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_includedirs
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_linkdirs _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_linkdirs
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_links _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_links
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_subdirs _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/add_subdirs
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/is_os _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/is_os
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/is_plat _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/is_plat
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_basename _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_basename
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_headerdir _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_headerdir
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_kind _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_kind
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_languages _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_languages
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_objectdir _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_objectdir
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_optimize _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_optimize
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_project _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_project
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_strip _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_strip
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_symbols _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_symbols
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_targetdir _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_targetdir
_detact_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_warnings _detach_bundle xmake.vim rplugin/python3/deoplete/sources/docs/set_warnings
;; ;;
scrollbar.vim) scrollbar.vim)
git clone https://github.com/wsdjeg/scrollbar.vim.git detach/$1 git clone https://github.com/wsdjeg/scrollbar.vim.git detach/$1
@ -447,11 +447,11 @@ EOT
_checkdir autoload/SpaceVim/plugins/ _checkdir autoload/SpaceVim/plugins/
_detact autoload/SpaceVim/plugins/scrollbar.vim _detact autoload/SpaceVim/plugins/scrollbar.vim
_detact LICENSE _detact LICENSE
_detact_bundle scrollbar.vim README.md _detach_bundle scrollbar.vim README.md
_checkdir plugin _checkdir plugin
_detact_bundle scrollbar.vim plugin/scrollbar.vim _detach_bundle scrollbar.vim plugin/scrollbar.vim
_checkdir test _checkdir test
_detact_bundle scrollbar.vim test/vimrc _detach_bundle scrollbar.vim test/vimrc
_checkdir lua/spacevim/plugin _checkdir lua/spacevim/plugin
_detact lua/spacevim/plugin/scrollbar.lua _detact lua/spacevim/plugin/scrollbar.lua
_checkdir lua/spacevim/api/vim _checkdir lua/spacevim/api/vim
@ -465,11 +465,11 @@ EOT
_checkdir plugin/ _checkdir plugin/
_checkdir autoload/ _checkdir autoload/
_detact LICENSE _detact LICENSE
_detact_bundle github.vim autoload/github.vim _detach_bundle github.vim autoload/github.vim
_detact_bundle github.vim plugin/github.vim _detach_bundle github.vim plugin/github.vim
_default_readme "GitHub.vim" "GitHub API support for neovim/vim[wip]" _default_readme "GitHub.vim" "GitHub API support for neovim/vim[wip]"
_checkdir doc/ _checkdir doc/
_detact_bundle github doc/github.txt _detach_bundle github doc/github.txt
;; ;;
esac esac
git add . git add .

View File

@ -35,12 +35,15 @@ Plug 'wsdjeg/git.vim'
- `:Git add .`: stage all files - `:Git add .`: stage all files
- `:Git commit`: edit commit message - `:Git commit`: edit commit message
- `:Git push`: push to remote - `:Git push`: push to remote
- `:Git pull`: pull updates from remote
- `:Git fetch`: fetch remotes - `:Git fetch`: fetch remotes
- `:Git checkout`: checkout branches - `:Git checkout`: checkout branches
- `:Git log %`: view git log of current file - `:Git log %`: view git log of current file
- `:Git config`: list all git config - `:Git config`: list all git config
- `:Git reflog`: manage reflog information - `:Git reflog`: manage reflog information
- `:Git branch`: list, create, or delete branches - `:Git branch`: list, create, or delete branches
- `:Git rebase`: rebase git commit
- `:Git diff`: view git-diff info
## Screenshot ## Screenshot

View File

@ -1,47 +1,69 @@
let s:JOB = SpaceVim#api#import('job') "=============================================================================
let s:NOTI = SpaceVim#api#import('notify') " checkout.vim --- checkout command
" Copyright (c) 2016 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
function! git#checkout#run(args) ""
" @section git-checkout, checkout
" @parentsection commands
" This comamnd is to switch branches or restore working tree files.
" >
" :Git checkout -b new_branch_name
" <
if has('nvim-0.9.0')
function! git#checkout#complete(ArgLead, CmdLine, CursorPos) abort
return luaeval('require("git.command.checkout").complete(vim.api.nvim_eval("a:ArgLead"), vim.api.nvim_eval("a:CmdLine"), vim.api.nvim_eval("a:CursorPos"))')
endfunction
else
let s:JOB = SpaceVim#api#import('job')
let s:NOTI = SpaceVim#api#import('notify')
function! git#checkout#run(args)
let cmd = ['git', 'checkout'] + a:args let cmd = ['git', 'checkout'] + a:args
call git#logger#debug('git-checkout cmd:' . string(cmd)) call git#logger#debug('git-checkout cmd:' . string(cmd))
call s:JOB.start(cmd, call s:JOB.start(cmd,
\ { \ {
\ 'on_exit' : function('s:on_exit'), \ 'on_exit' : function('s:on_exit'),
\ } \ }
\ ) \ )
endfunction endfunction
function! s:on_exit(id, data, event) abort function! s:on_exit(id, data, event) abort
call git#logger#debug('git-checkout exit data:' . string(a:data)) call git#logger#debug('git-checkout exit data:' . string(a:data))
if a:data ==# 0 if a:data ==# 0
silent! checktime silent! checktime
call s:NOTI.notify('checkout done.') call s:NOTI.notify('checkout done.')
call git#branch#detect() call git#branch#detect()
else else
call s:NOTI.notify('checkout failed.', 'WarningMsg') call s:NOTI.notify('checkout failed.', 'WarningMsg')
endif endif
endfunction endfunction
function! s:options() abort function! s:options() abort
return join([ return join([
\ '-m', \ '-m',
\ '-b', \ '-b',
\ ], "\n") \ ], "\n")
endfunction endfunction
function! git#checkout#complete(ArgLead, CmdLine, CursorPos) function! git#checkout#complete(ArgLead, CmdLine, CursorPos)
if a:ArgLead =~# '^-' if a:ArgLead =~# '^-'
return s:options() return s:options()
endif endif
let branchs = systemlist('git branch') let branchs = systemlist('git branch')
if v:shell_error if v:shell_error
return '' return ''
else else
let branchs = join(map(filter(branchs, 'v:val !~ "^*"'), 'trim(v:val)'), "\n") let branchs = join(map(filter(branchs, 'v:val !~ "^*"'), 'trim(v:val)'), "\n")
return branchs return branchs
endif endif
endfunction endfunction
endif

View File

@ -3,18 +3,19 @@ Wang Shidong & Mattes Groeger *git*
============================================================================== ==============================================================================
CONTENTS *git-contents* CONTENTS *git-contents*
1. Introduction..................................................|git-intro| 1. Introduction................................................... |git-intro|
2. Commands...................................................|git-commands| 2. Commands.................................................... |git-commands|
1. git-add.....................................................|git-add| 1. git-add...................................................... |git-add|
2. git-branch...............................................|git-branch| 2. git-branch................................................ |git-branch|
3. git-cherry-pick.....................................|git-cherry-pick| 3. git-checkout............................................ |git-checkout|
4. git-clean.................................................|git-clean| 4. git-cherry-pick...................................... |git-cherry-pick|
5. git-mv.......................................................|git-mv| 5. git-clean.................................................. |git-clean|
6. git-reflog...............................................|git-reflog| 6. git-mv........................................................ |git-mv|
7. git-rm.......................................................|git-rm| 7. git-reflog................................................ |git-reflog|
8. git-stash.................................................|git-stash| 8. git-rm........................................................ |git-rm|
9. git-tag.....................................................|git-tag| 9. git-stash.................................................. |git-stash|
3. Functions.................................................|git-functions| 10. git-tag..................................................... |git-tag|
3. Functions.................................................. |git-functions|
============================================================================== ==============================================================================
INTRODUCTION *git-intro* INTRODUCTION *git-intro*
@ -45,6 +46,14 @@ This commands is to open branch manager.
:Git branch :Git branch
< <
==============================================================================
GIT-CHECKOUT *git-checkout*
This comamnd is to switch branches or restore working tree files.
>
:Git checkout -b new_branch_name
<
============================================================================== ==============================================================================
GIT-CHERRY-PICK *git-cherry-pick* GIT-CHERRY-PICK *git-cherry-pick*

View File

@ -27,4 +27,22 @@ function M.run(argv)
job.start(cmd, { on_exit = on_exit }) job.start(cmd, { on_exit = on_exit })
end end
function M.complete(arglead, cmdline, cursorpos)
if vim.startswith(arglead, '-') then
return table.concat({ '-b', '-m' }, '\n')
end
local branchs = vim.fn.systemlist('git branch')
return table.concat(
vim.tbl_map(
function(t)
return vim.fn.trim(t)
end,
vim.tbl_filter(function(t)
return not vim.startswith(t, '*')
end, branchs)
),
'\n'
)
end
return M return M

View File

@ -633,6 +633,7 @@ local function handle_input(input)
start_buffer() start_buffer()
else else
winclose() winclose()
vim.cmd('doautocmd WinEnter,BufEnter')
prefix_key_inp = {} prefix_key_inp = {}
cmp.fn.feedkeys(vis .. reg .. count, 'ti') cmp.fn.feedkeys(vis .. reg .. count, 'ti')
@ -731,7 +732,7 @@ wait_for_input = function()
undo_history = {} undo_history = {}
guide_help_mode = false guide_help_mode = false
winclose() winclose()
vim.cmd('doautocmd WinEnter') vim.cmd('doautocmd WinEnter,BufEnter')
elseif guide_help_mode then elseif guide_help_mode then
submode_mappings(inp) submode_mappings(inp)
guide_help_mode = false guide_help_mode = false
@ -753,7 +754,7 @@ wait_for_input = function()
handle_input(fsel) handle_input(fsel)
else else
winclose() winclose()
vim.cmd('doautocmd WinEnter') vim.cmd('doautocmd WinEnter,BufEnter')
local keys = prefix_key_inp local keys = prefix_key_inp
local name = M.getName(prefix_key) local name = M.getName(prefix_key)
local _keys = vim.fn.join(keys, '-') local _keys = vim.fn.join(keys, '-')