Skip to content

Commit

Permalink
✨feat: GitAddAll関数を好きな引数を指定できるようにコマンド化
Browse files Browse the repository at this point in the history
  • Loading branch information
utubo committed Oct 2, 2023
1 parent 6bd47a4 commit bd3e731
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
23 changes: 12 additions & 11 deletions .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -253,33 +253,34 @@ nn <buffer> <F1> <Cmd>:q!<CR>
nn <buffer> p <Plug>(fern-action-leave)
}
nn <F1> <Cmd>Fern . -reveal=% -opener=split<CR>
def I()
const a = getcwd()
def I(a: string)
const b = getcwd()
try
chdir(expand('%:p:h'))
echoh MoreMsg
ec 'git add -A -n'
const b = system('git add -A -n')
if !b
ec 'git add -n ' .. a
const c = system('git add -n ' .. a)
if !c
ec 'none.'
elseif !!v:shell_error
echoh ErrorMsg
ec b
ec c
echoh Normal
return
else
echoh DiffAdd
ec b
ec c
echoh Question
if input("execute ? (y/n) > ", 'y') ==# 'y'
system("git add -A")
if input('execute ? (y/n) > ', 'y') ==# 'y'
system('git add ' .. a)
endif
endif
echoh Normal
finally
chdir(a)
chdir(b)
endtry
enddef
com! -nargs=* GitAdd I(<f-args>)
def! g:ConventionalCommits(a: any, l: string, p: number): list<string>
return ['✨feat:', '🐞fix:', '📝docs:', '🔨refactor:', '🎨style:', '⏪revert:', '✅test:', '🔧chore', '🎉release:']
enddef
Expand All @@ -289,7 +290,7 @@ ec system($"git tag '{a}'")
ec system($"git push origin '{a}'")
enddef
com! -nargs=1 GitTagPush J(<q-args>)
nn <Space>ga <ScriptCmd>I()<CR>
nn <Space>ga <ScriptCmd>I('-A')<CR>
nn <Space>gA :<C-u>Git add %
nn <Space>gc :<C-u>GitCommit<Space><Tab>
nn <Space>gp :<C-u>Git push
Expand Down
13 changes: 7 additions & 6 deletions src/.vimrc.src.vim
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,13 @@ nnoremap <F1> <Cmd>Fern . -reveal=% -opener=split<CR>
#}}}

# Git {{{
def GitAddAll()
def GitAdd(args: string)
const current_dir = getcwd()
try
chdir(expand('%:p:h'))
echoh MoreMsg
echo 'git add -A -n'
const list = system('git add -A -n')
echo 'git add -n ' .. args
const list = system('git add -n ' .. args)
if !list
echo 'none.'
elseif !!v:shell_error
Expand All @@ -350,15 +350,16 @@ def GitAddAll()
echoh DiffAdd
echo list
echoh Question
if input("execute ? (y/n) > ", 'y') ==# 'y'
system("git add -A")
if input('execute ? (y/n) > ', 'y') ==# 'y'
system('git add ' .. args)
endif
endif
echoh Normal
finally
chdir(current_dir)
endtry
enddef
command! -nargs=* GitAdd GitAdd(<f-args>)
def! g:ConventionalCommits(a: any, l: string, p: number): list<string>
return ['✨feat:', '🐞fix:', '📝docs:', '🔨refactor:', '🎨style:', '⏪revert:', '✅test:', '🔧chore', '🎉release:']
enddef
Expand All @@ -368,7 +369,7 @@ def GitTagPush(tagname: string)
echo system($"git push origin '{tagname}'")
enddef
command! -nargs=1 GitTagPush GitTagPush(<q-args>)
nnoremap <Space>ga <ScriptCmd>GitAddAll()<CR>
nnoremap <Space>ga <ScriptCmd>GitAdd('-A')<CR>
nnoremap <Space>gA :<C-u>Git add %
nnoremap <Space>gc :<C-u>GitCommit<Space><Tab>
nnoremap <Space>gp :<C-u>Git push
Expand Down

0 comments on commit bd3e731

Please sign in to comment.