phiresky / ripgrep-all

rga: ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc.
Other
8.04k stars 173 forks source link

FR: Use RGA for VSCode Search #257

Open codexwest opened 2 days ago

codexwest commented 2 days ago

I believe VS Code uses ripgrep under the hood to search across all files in the opened directory(s) (https://github.com/microsoft/vscode-ripgrep?tab=readme-ov-file).

I'd be curious how feasible it would be to drop in ripgrep-all instead of ripgrep so that VS Code provides richer search results for PDF etc. I know this breaks down at some point, e.g. in VS Code you click on a result to jump to the line number where the match is found, and that might not be possible for many files with rga. Still, I think about this daily and even just opening the file itself is rga detects a match would be very helpful.

I'm not very familiar with the input argument syntax for rg vs rga, so I'm not sure if this would be very easy or very hard to accomplish - curious to hear feedback.

phiresky commented 2 days ago

I think you can choose the path to rga somewhere in VSCode settings? just setting that to rga might work

lafrenierejm commented 2 days ago

Agreed with phiresky's suggestion. rga CLI is fully compatible with rg's, so you should be able to use it as a drop-in replacement. Results from non-plaintext sources might give weird results if you select them in the editor, though.

codexwest commented 1 day ago

Thanks for the info, good to know that the CLI is compatible. The rg executable for VS Code in MacOS with M1 processor is located at /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules.asar.unpacked/@vscode/ripgrep/bin/rg. Just replacing rg here with latest apple-darwinrga (and then renaming rga to rg) unfortunately doesn't work as VS Code's default search never completes now for any filetypes (though it at least doesn't throw an error as it does with the linux variant). So perhaps they are doing something in their custom rg build or verifying the install, or somehow using ripgrep in another way than the fully-compatible CLI. I tested the same thing for the Windows 10 variants and paths (C:\Users\username\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar.unpacked\@vscode\ripgrep\bin\rg.exe), with same results (no error, but searches never complete).

image

codexwest commented 1 day ago

I think you can choose the path to rga somewhere in VSCode settings? just setting that to rga might work

There isn't a setting for this but as I my last comment shows, you can just go replace the executables which has the same effect.

phiresky commented 1 day ago

rga might require rg and rga-preproc to be next to the rga binary make sure those are there

codexwest commented 1 day ago

Good point. Looks like it doesn't make a difference though. I tried renaming them to rg-preproc etc. as a long shot but of course that also didn't work.

phiresky commented 17 hours ago

yeah, could be that vscode calls rga but then rga calls the "rg" binary which is just rga again so it's an endless loop