diff --git a/.vimrc b/.vimrc index 9cf53d6..4941b17 100644 --- a/.vimrc +++ b/.vimrc @@ -254,25 +254,31 @@ nn p (fern-action-leave) } nn Fern . -reveal=% -opener=split def I() +const a = getcwd() +try +chdir(expand('%:p:h')) echoh MoreMsg ec 'git add -A -n' -const a = system('git add -A -n') -if !a +const b = system('git add -A -n') +if !b ec 'none.' elseif !!v:shell_error echoh ErrorMsg -ec a +ec b echoh Normal return else echoh DiffAdd -ec a +ec b echoh Question if input("execute ? (y/n) > ", 'y') ==# 'y' system("git add -A") endif endif echoh Normal +finally +chdir(a) +endtry enddef def! g:ConventionalCommits(a: any, l: string, p: number): list return ['✨feat:', '🐞fix:', '📝docs:', '🔨refactor:', '🎨style:', '⏪revert:', '✅test:', '🔧chore', '🎉release:'] diff --git a/src/.vimrc.src.vim b/src/.vimrc.src.vim index 11c4319..64b9e62 100644 --- a/src/.vimrc.src.vim +++ b/src/.vimrc.src.vim @@ -333,25 +333,31 @@ nnoremap Fern . -reveal=% -opener=split # Git {{{ def GitAddAll() - echoh MoreMsg - echo 'git add -A -n' - const list = system('git add -A -n') - if !list - echo 'none.' - elseif !!v:shell_error - echoh ErrorMsg - echo list - echoh Normal - return - else - echoh DiffAdd - echo list - echoh Question - if input("execute ? (y/n) > ", 'y') ==# 'y' - system("git add -A") + const current_dir = getcwd() + try + chdir(expand('%:p:h')) + echoh MoreMsg + echo 'git add -A -n' + const list = system('git add -A -n') + if !list + echo 'none.' + elseif !!v:shell_error + echoh ErrorMsg + echo list + echoh Normal + return + else + echoh DiffAdd + echo list + echoh Question + if input("execute ? (y/n) > ", 'y') ==# 'y' + system("git add -A") + endif endif - endif - echoh Normal + echoh Normal + finally + chdir(current_dir) + endtry enddef def! g:ConventionalCommits(a: any, l: string, p: number): list return ['✨feat:', '🐞fix:', '📝docs:', '🔨refactor:', '🎨style:', '⏪revert:', '✅test:', '🔧chore', '🎉release:']