Closed noscript closed 10 years ago
I agree that ideally EasyGrep would not limit users to certain external tools. Note that the issue isn't so much about grepprg validation but moreso about how the external grep command is constructed. When building up the grep command, EasyGrep will parameterize the command string via program-specific settings that control pattern-specification, pattern-escaping, case-sensitivity, whole-word, recursion, file inclusions, file exclusions, etc. Adding an option for a custom grep command means that EasyGrep would need a mechanism to allow the user to parameterize each and every one of these (potentially complex) settings for their custom program. This would actually be a strong improvement to the internal logic of the script as it would decouple the logic of the command creation from the particular command that is being used. It's a bit of work, though, and it would require a somewhat large refactoring. There is also the possibility that the user specifies their customer parameters incorrectly yet blames EasyGrep for the errors they encounter. In summary, while I like the idea, it's not a trivial edit. I'll give it some thought, though.
Another complain about external tool discrimination, search with whitespace or selected text search doesn't get wrapped into quotes.
Setup 1
:set grepprg=ag\ --nocolor\ --nogroup\ --column
:Grep Hello World
Generated grepCommand
:
grep! -i "Hello World" /test
Everything works great, since "Hello World" is escaped.
Setup 2
:set grepprg=git\ grep\ -n
:Grep Hello World
Generated grepCommand
:
grep! -i Hello World /test
Result:
|| fatal: ambiguous argument 'World': unknown revision or path not in the working tree.
|| Use '--' to separate paths from revisions, like this:
|| 'git <command> [<revision>...] -- [<file>...]
Of course I can do :Grep "Hello World"
manually, but I have no control over selection search.
I would be just happy if git grep
was supported out-of-the-box. Will you accept a pull request if I add the support myself?
HI Sergey,
I just submitted a commit that starts the work for custom external grep tools. I also implemented basic support for git grep at that time. Can you check it out and see if it works for you? If you encounter any issues please let me know. If you want to take a stab at improvements for the support feel free to do so and I will accept the pull request.
Thanks,
Dan
Hello Dan,
It works great! Big thank you. I will continue using/testing it and let you know if anything additional needed.
BR, Sergey
Shouldn't
s:ValidateGrepCommand()
skip validation when usingg:EasyGrepCommand=1
andgrepprg
set to something else but ack or grep?I use git-grep and it works great with easygrep (via patching
s:ValidateGrepCommand()
). I think there is no need to limit users to certain external tools.