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

Ripgrep flag 'w' doesn't work #49

Closed
abenz1267 opened this issue Feb 13, 2020 · 5 comments
Closed

Ripgrep flag 'w' doesn't work #49

abenz1267 opened this issue Feb 13, 2020 · 5 comments

Comments

@abenz1267
Copy link

Hi,

it seems like ripgreps -w/--word-regexp flag doesn't work.

AttributeError: 'NoneType' object has no attribute 'group'

Is this intended or a bug?

Regards

@yuki-yano
Copy link
Owner

It seems to work in my environment.
Can you give an example of failure using this repository?
11

@abenz1267
Copy link
Author

Hi,

using it that way works. I put this in my init.vim

let g:fzf_preview_grep_cmd = 'rg --line-number --no-heading -w'
nmap <silent> <A-p> :FzfPreviewProjectGrep<CR>

When i alt+p i got the error straight away. Weirdly now i don't get an error, but it isn't working either.

Regards

@yuki-yano
Copy link
Owner

If no argument is given, FzfPreviewProjectGrep executes a command with a dot after g:fzf_preview_grep_cmd and searches for the project.
Thus, when run without arguments, rg -w . is run.
https://github.com/yuki-ycino/fzf-preview.vim/blob/master/autoload/fzf_preview/command.vim#L21-L27

Adding the -w option seems to require passing the argument each time the command is executed, or specifying the -w option at runtime instead of writing g: fzf_preview_grep_cmd.

Not yet documented, but if necessary, you can easily create new resources using the fzf_preview#parameter and the fzf_preview#runner.
https://github.com/yuki-ycino/fzf-preview.vim/blob/master/autoload/fzf_preview/parameter.vim#L82-L91
https://github.com/yuki-ycino/fzf-preview.vim/blob/master/autoload/fzf_preview/runner.vim

@abenz1267
Copy link
Author

-w option at runtime instead of writing g: fzf_preview_grep_cmd

What do you mean? Typing '-w ' in the preview window doesn't work. Or do you mean directly running FzfPreviewGrep -w <search> as you did? Yes, that works.

Btw: is it possible to remove the files list when the input is empty?

Regards

@yuki-yano
Copy link
Owner

Sorry for not good at english.

fzf narrows the candidates from the list passed at startup.
Therefore, you need to create a candidate list first.
It is possible to use the -w option at that time.
However, after the candidate is passed to fzf, rg is not relevant, so the -w option cannot be used.

FzfPreviewProjectGrep uses . without arguments to use all lines of the project, which is necessary to pass candidates to fzf.

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

2 participants