Closed lucapette closed 12 years ago
protip: if you cd
to the project directory Ack will use it as the root directory, so no need to set a default directory or pass it as an argument at each call... (not sure if that solves your use case tho)
Yes. I think for the most part, this is unnecessary for the very reason @millermedeiros mentioned.
@millermedeiros You're right obviously. I'm very familiar with this prototip but it doesn't consider the autochdir option that I need for other things. So, if you run, say, vi app/models/user.rb
and you have set autochdir
in your vimrc then a Ack.vim willl search in app/models by default.
I'm not saying it's a good idea to accept the pull request (It contains a bug I've just found out and I'm going to fix it) but maybe it could be useful to consider the idea behind my pull request.
@lucapette I commented since other people may have a similar desire and not notice the default behavior (protip was just to point my comment was probably obvious), also because I couldn't understand why you need to config a defaultdir since every time I need to search inside different folders and cd
is enough to me.
Well, it looks like this won't be merged.
FWIW, I have the autochdir
option set and use it for :e
and :vsp
commands. I'd love an option to set a default directory specific to ackvim.
It would be nice if Ack root dir worked similar to CtrlP 'ctrlp_working_path_mode' r option - automatically figuring out the root path
I agree with @vvzz . I'm an autochdir
user and also like how CtrlP determines the root path.
+1 for this merge
@lucapette maybe you should also give the default example of setting this option to the root of git or svn project root directory.
@noscripter See #188 for my recent perspective on basically this same idea. There are a number of ways to skin this cat and I'm not convinced it's within the scope of the search plugin to solve it. Projectionist's :ProjectDo
is likely a good option if you use that plugin.
One possibility is a variable convention like the one in this proposal, expanded by your own mapping or abbreviation that invokes an :Ack
command with the path filled. Personally I would do this with a buffer-local variable and set that variable as desired via something like localvimrc for each project where I want it, or try to detect a .git
if that's your use case (a global g:
var is not the appropriate scope for this IMO, I might work on multiple "projects" within one Vim instance and twiddling a single global var then becomes a mess). This should be entirely doable by the user without the plugin needing any specific support for it, such is the beauty of Vim's scriptability.
I can understand how this could be helpful for 'autochdir'
users, however (though some may want/expect exactly the opposite: for ack.vim
to respect 'autochdir'
just like :grep
does…). If anyone cooks up a solution like this I'd be glad to include it as a recipe in documentation. If it turns out to be clean and simple enough I might consider including it, but I don't want something as complicated as CtrlP's configuration approach.
I added this option because I don't like the idea of typing in the root of a project at every search. I find that Ack.vim is particularly useful when I can do project-searches. To be honest, I don't know if this is a good way of implementing it. It's working fine with me at the moment and I have done a pull-request just for sharing the idea. If you like it, I can do another commit with docs.
Thank you for the plugin!