Closed tlelson closed 1 year ago
I've never needed this because I always stay in the project root once I start Vim. I'm genuinely curious, is there any reason you switch directories?
Having said that, I'm not against adding an option. Need to put more thought into what would be the most convenient and flexible way to configure the behavior.
This happens for me if I've followed code into a standard or third party library package somewhere. It also happens if I've opened up some reference code/document or opened vim configurations or plugin code.
Perhaps its only relevant to those using autochdir
since that will localize any actions to the buffer's location.
@tlelson I have the same use case as you and I have addressed it via: https://github.com/airblade/vim-rooter
By setting vim's working directory to the project root, you get the added benefit of other cwd-centric tools working as expected also.
Perhaps it betrays my low maturity level but I haven't been able to visit the project without a chuckle. Nonetheless, a smarter version of autochdir
is what I'm looking for. Thanks @michaelorr I shall give it a go.
Initially, I came in here looking for an equivalent to :GFiles
for :Rg
(grepping any file in the current repo). But @junegunn's remark about immediately starting vim in my project's root directory has me questioning my workflow (and for now serves as a pretty good solution to my problem).
man fzf
)I have defined commands similar to the plugin default commands that use the git root as the
dir
argument. Example:I don't want to redefine
Rg
because I find it very useful to search from the current buffers path just as often as searching the whole project.I have a growing list of commands that closely shadow their original version.
I would like to provide an argument instead but I see that this would conflict with the underlying command's arguments.
I'd be happy to contribute a PR if it were deemed valuable and achievable in a way consistent with the rest of the project.
Would anyone else find it useful to easily switch the following commands between buffer cwd and git root?
Rg
,Files
,GFiles
...