That's actually a builtin. (here's the help link)
:set autochdir
Stick that in your .vimrc or whatnot (:e $MYVIMRC
). As mentioned here, sometimes plugins will have issues with that and you need to use something more complicated like
autocmd BufEnter * lcd %:p:h