airblade / vim-rooter

Changes Vim working directory to project root.
MIT License
1.21k stars 72 forks source link

Can it work for non-exist file #130

Closed Freed-Wu closed 1 year ago

Freed-Wu commented 1 year ago

Such as:

vi /the/path/of/a/non-exist/file

And /the/path/.git exist. Rooter will not cd to /the/path.

However:

touch /the/path/of/a/non-exist/file
vi /the/path/of/a/non-exist/file

Rooter will cd to /the/path.

So Rooter is only work for BufRead not BufNewFile, really? How can make it work for BufNewFile? Thanks!

airblade commented 1 year ago

The file has to exist on disk for vim-rooter to be able to check its parent/siblings/descendants with glob patterns.

As soon as you write your new file, vim-rooter will change directory to the root.