direnv,vim: add 'add_extra_vimrc'

This commit is contained in:
surtur 2022-05-06 22:52:07 +02:00
parent b644866ff9
commit b42920e007
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
2 changed files with 15 additions and 0 deletions

8
.config/direnv/direnvrc Normal file

@ -0,0 +1,8 @@
# as per https://github.com/direnv/direnv/wiki/Vim
add_extra_vimrc() {
local extravim="$(find_up .vimrc)"
if [ -n "$extravim" ]; then
echo "Adding extra .vimrc: ${extravim}"
path_add EXTRA_VIM $extravim
fi
}

@ -562,3 +562,10 @@ imap a <M-A>
nnoremap <Leader>ve :e $MYVIMRC<CR> nnoremap <Leader>ve :e $MYVIMRC<CR>
nnoremap <Leader>vr :source $MYVIMRC<CR> nnoremap <Leader>vr :source $MYVIMRC<CR>
" as per https://github.com/direnv/direnv/wiki/Vim
if exists("$EXTRA_VIM")
for path in split($EXTRA_VIM, ':')
exec "source ".path
endfor
endif