Skip to content
Jonas Chevalier edited this page Mar 20, 2022 · 4 revisions

A couple of config snippets:

In ~/.config/direnv/direnvrc:

add_extra_vimrc() {
  local extravim="$(find_up .vimrc)"
  if [ -n "$extravim" ]; then
    echo "Adding extra .vimrc: ${extravim}"
    path_add EXTRA_VIM $extravim
  fi
}

In ~/.vimrc:

if exists("$EXTRA_VIM")
  for path in split($EXTRA_VIM, ':')
    exec "source ".path
  endfor
endif

Now, you can put this in a .envrc

add_extra_vimrc

and safely approve a per-project .vimrc. As a for instance, I'm configuring CtrlP's ignore list on a per-project basis.

direnv plugin

There's also the experimental direnv plugin that interacts with direnv to update vim's environment variables: https://github.com/zimbatm/direnv.vim

Clone this wiki locally