mhinz / vim-grepper

:space_invader: Helps you win at grep.
MIT License
1.22k stars 58 forks source link

The -buffer flag has no effect #258

Closed pluma9 closed 9 months ago

pluma9 commented 2 years ago

Reproduce

Given: 3 files containing the same content. Open one of the files and run the following command:

:Grepper -tool rg -buffer -noprompt -query hello

Result:

file1|1 col 1| hello world file3|1 col 1| hello world file2|1 col 1| hello world file1|1 col 1| hello world hello: The system cannot find the file specified. (os error 2)||

The vim command was translated to: rg -H --no-heading --vimgrep hello . -- hello "file1", which is incorrect I think.

Expectation

Only search the content in file1

Environment

Windows 10 Education x86_64 NVIM v0.8.0-dev+272-g5193b1783 ripgrep 13.0.0 vim-grepper commit 2b93535752ffcb312f9fab73d90e80dc9f2e60fc

lbonn commented 9 months ago

It looks like a windows issue https://github.com/mhinz/vim-grepper/commit/9b62e6bdd9de9fe027363bbde68e9e32d937cfa0

Do you have a command that would work that you would be able to test on windows (by doing let g:grepper.rg.grepprg = ...)?

pluma9 commented 9 months ago

I don't have such command.

This works:

let g:grepper.rg.grepprg='rg -H --no-heading --vimgrep $* file1'

But this does not:

let g:grepper.rg.grepprg='rg -H --no-heading --vimgrep $* $.'

Failed to detect indentation style. Error detected while processing function 32_parse_flags[84]..32_start[16]..32_run[3]..BufReadPost Autocommands for "quickfix"..function 52_OnQuickfixInit[10]..BufWriteCmd Autocommands for "quickfix-5"..function 52_OnWrite[79]..52_setQfOrLocationList: line 4: E952: Autocommand caused recursive behavior Error detected while processing function 32_parse_flags[84]..32_start[16]..32_run[10]..32_build_cmdline: line 18: E716: Key not present in Dictionary: "buflist[0], '')" E116: Invalid arguments for function substitute Running: -1

lbonn commented 9 months ago

@pluma9 yes it looks like the work-around is not needed anymore (for a while I guess...).

I've tried it and it seems to work, let me know if it's still causing issues.

pluma9 commented 9 months ago

Sorry @lbonn , I still face this problem.

What I meant in the previous comment is, it works if I explicitly use file1, but for some reason, it does not work if I use the $. placeholder.

However, I guess that's another problem. The main and original problem is related to the -buffer

If you look at the resulted command in the issue description at the top,

rg -H --no-heading --vimgrep hello . -- hello "file1"

why are there two hellos?

Shouldn't it be something like below?

rg -H --no-heading --vimgrep hello "file1"
lbonn commented 9 months ago

@pluma9 can you try again with the latest revision, including this commit https://github.com/mhinz/vim-grepper/commit/485d349125d46f2788833ecb43df7a14c46706f6?

pluma9 commented 8 months ago

I am now at https://github.com/mhinz/vim-grepper/commit/485d349125d46f2788833ecb43df7a14c46706f6 and it works like a charm.

Thanks. I really appreciate your support!

lbonn commented 8 months ago

No worries, better late than never I guess :)