vim-rooter
vim-rooter copied to clipboard
Respect user's &autochdir for not triggered buffer
For buffers that won't trigger rooter, we can respect user's &autochdir setting for them unchanged.
Can't you get the same behaviour by allowing rooter to run for all buffers and having let g:rooter_change_directory_for_non_project_files = 'current'
?
No, I tried it.
And the reason for it is that, your code will for g:rooter_change_directory_for_non_project_files
only applies to triggered buffers.
In fact, I thought, it is a design mistake in your code. Because your non_project_files
actually means files considered by g:rooter_targets
which are not in a project folder. But from common sense, file not considered by g:rooter_targets
are usually non_project_files
.
I say so, since as you can recall
https://github.com/airblade/vim-rooter/blob/544e701066c69bbeb45297d0285c2719e125440b/plugin/rooter.vim#L68-L70
your code skips non triggered files.
But why not trigger rooter in all buffers then?
Sorry, I was modifying my last comment since I realized I overlooked your first comment. I didn't see you mentioned enable for all buffers.
I thought, as your README suggests, user has choice for which buffer to be triggered.
Your suggestion sounds like a workaround. I think there is need to have control both over triggered buffers and project patterns. I suspect this is what users will expect.
Your perspective is also reasonable.
It is understandable for you to keep your opinion on how people think for project files.
I think it all depends on which way you look at it.
When I first wrote rooter it ran for every buffer and g:rooter_change_directory_for_non_project_files
configured how to handle files which weren't under a "root".
Later on g:rooter_targets
appeared in the code, mainly as a way to configure whether rooter should run on directories or just files. However I can see how one could almost use it to pre-define which files are under a root – and if you do that, you don't need g:rooter_change_directory_for_non_project_files
.
Personally I find it easier to get rooter to run on every buffer (i.e. g:rooter_targets == '/,*'
) than to specify certain file extensions as targets. For me it doesn't work so well to say "these file extensions are always under a root" because sometimes they aren't, and sometimes other file extensions are.
Thanks for your historical explanation, now I get more of your idea.