airblade / vim-rooter

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

User configurable "get file path from buffer" function #136

Closed tpict closed 4 months ago

tpict commented 5 months ago

I was recently trying out https://github.com/stevearc/oil.nvim, but found that it didn't trigger vim-rooter because the buffer name is prefixed with oil://.

Would it be possible to add a configuration option for a function that receives a buffer, and returns a file path? It would default to expand('%') (or whatever the current behavior is). Then the user could filter out URI protocols etc as needed.

This could also be used to enable things like syncing with the active directory in a Neovim terminal buffer.

Thanks!

airblade commented 5 months ago

Are all buffer names prefixed with oil:// or just buffers holding directory listings?

vim-rooter gets the current path in a few places:

The latter two call s:current().

Now that I write it out, I'm not sure why the first one doesn't just call s:current().

Are you asking for s:current() to be replaceable by a user-supplied function?

tpict commented 5 months ago

Are all buffer names prefixed with oil:// or just buffers holding directory listings?

yep, the latter

Are you asking for s:current() to be replaceable by a user-supplied function?

I think so, yeah, possibly with the option to return v:null to fall back to the default behavior.

airblade commented 5 months ago

Ok, and what problem is vim-rooter causing by not triggering on a directory listing?

tpict commented 5 months ago

With other plugins that do the same thing (dirvish, dirbuf.nvim), vim-rooter is triggered when navigating directories, which is desirable for me 😄

airblade commented 4 months ago

Please can you try out the branch in #137?