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

FR: Use RGA for VSCode Search #257

Open
codexwest opened this issue Oct 4, 2024 · 7 comments
Open

FR: Use RGA for VSCode Search #257

codexwest opened this issue Oct 4, 2024 · 7 comments

Comments

@codexwest
Copy link

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
Copy link
Owner

phiresky commented Oct 4, 2024

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

@lafrenierejm
Copy link
Contributor

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
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

phiresky commented Oct 5, 2024

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

@codexwest
Copy link
Author

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
Copy link
Owner

phiresky commented Oct 6, 2024

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

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

3 participants