Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with vim/neovim and fzf.vim #81

Closed
chopfitzroy opened this issue Sep 25, 2016 · 14 comments
Closed

Usage with vim/neovim and fzf.vim #81

chopfitzroy opened this issue Sep 25, 2016 · 14 comments

Comments

@chopfitzroy
Copy link

I am trying to set this up with fzf.vim and as per this comment rg does not seem to currently work.

I was hoping you would have some insight into this?

Cheers.

@chopfitzroy chopfitzroy changed the title Usage with vim/neovim Usage with vim/neovim and fzf.vim Sep 25, 2016
@junegunn
Copy link

Another problem I noticed is this:

rg-column

I don't think it's intentional?

@mengelbrecht
Copy link

You mean the missing line numbers? If the output is not to a tty the parameter for line numbers -n has to be explicitly specified.

@BurntSushi
Copy link
Owner

Yes, it is intentional. When searching at a tty, line numbers, headings and colors are enabled by default. Otherwise, the default format is the same as git grep.

I otherwise don't know what the problem is here. Could you please describe it in more detail?

@junegunn
Copy link

junegunn commented Sep 25, 2016

I see, so then it's not a problem. The issue we have is that the output of rg (0.1.17) is not captured by system() function of vim unlike grep or ag.

:echo system('ag foo')
:echo system('grep foo *')

:echo system('rg foo')

EDIT:

ag foo < /dev/null
grep foo * < /dev/null
rg foo < /dev/null

@BurntSushi
Copy link
Owner

I think rg and grep actually have the same behavior here. If you pass a file path argument, then stdin is ignored. The issue here is what happens when no path is given. Here's an illustration:

$ echo PM_RESUME | ag PM_RESUME | wc -l
1
$ ag PM_RESUME < /dev/null | wc -l
16
$ echo PM_RESUME | rg PM_RESUME | wc -l
1
$ rg PM_RESUME < /dev/null | wc -l
0

I bet this is the same bug that's being seen in #35.

@BurntSushi
Copy link
Owner

Hooray, this is indeed a dupe of #35! Fixing this fixes that too.

BurntSushi added a commit that referenced this issue Sep 25, 2016
If no paths are given to ripgrep, only read from stdin if it's a file or
a FIFO. In particular, if something like `rg foo < /dev/null` is used,
then don't try to read from stdin.

Fixes #35, #81
@BurntSushi
Copy link
Owner

Weird. Github didn't close this. Fixed in ab0d1c1.

@chopfitzroy
Copy link
Author

So just to clarify does rg need to be invoked with --column or --no-heading for this to now work?

Going of #35..?

Cheers.

@BurntSushi
Copy link
Owner

@CrashyBang I don't think the problem has actually been explained to me, but I imagine you'd want rg --no-heading --vimgrep.

@chopfitzroy
Copy link
Author

Hey @BurntSushi okay sweet will go over as soon as I am home from work will let you know how it goes hoping to do a write up on medium rg has already massively supercharged my workflow.

@BurntSushi
Copy link
Owner

@CrashyBang glad to hear it! Please send a link over if you do that write up. :-) (I'd also be happy to read a draft.)

@chopfitzroy
Copy link
Author

Hey @BurntSushi write up here: https://medium.com/@crashybang/supercharge-vim-with-fzf-and-ripgrep-d4661fc853d2 sorry wanted to get it up but still making tweaks if needed.

@junegunn
Copy link

@CrashyBang I would advise against suggesting -i and -e as the default. fzf by default performs smart-case matching which is really handy with CamelCase files. -i disables that and makes the search always case-insensitive. You might also want to experiment without -e especially because of the new scoring mechanism introduced in 0.15.0.

@chopfitzroy
Copy link
Author

chopfitzroy commented Sep 26, 2016

Hey @junegunn noted and removed :).

Otherwise it is okay?

amsharma91 added a commit to amsharma91/ripgrep that referenced this issue Sep 27, 2016
If no paths are given to ripgrep, only read from stdin if it's a file or
a FIFO. In particular, if something like `rg foo < /dev/null` is used,
then don't try to read from stdin.

Fixes BurntSushi#35, BurntSushi#81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants