title: Set vim current working directory to the current project root or to the directory of the current file
body: <p>How can I (automatically, basically I shouldn't have anything to do apart from initial configuration) set vim cwd to the project root directory (if there's any) or to the current buffer directory (in an <code>autochdir</code> fashion)?</p>
  
  <p>Here is an example of a file path to expected cwd: <code>~/foo/bar/SOME_FILE</code> -> <code>~/foo</code> if there is a <code>~/foo/.git/</code> dir or a <code>~/foo/.hg/</code> dir otherwise <code>~/foo/bar/</code></p>
  
  <p>I'm aware of <a href="https://github.com/airblade/vim-rooter" rel="noreferrer">airblade/vim-rooter</a> but it doesn't quite work (e.g. it relies on specific file extensions, and I don't want this behavior).</p>