5

I use counsel-projectile-rg to search within the project I work on. But there is my sub-project inside this big repo that most of my development is in.

Is there a way to sort ripgrep results based on the proximity to the current buffer that is open? Since I usually work in my sub-project directory I like to see matches in it's files first before the rest of the project.

Drew
  • 75,699
  • 9
  • 109
  • 225
SFbay007
  • 554
  • 4
  • 13
  • What does “proximity” mean? Do you mean the results from your buffer which are close to the current line? Or some complicated definition for nearby files? – Dan Robertson Jan 26 '20 at 11:52
  • If the path to the opened buffer is a/b/c/d/e/f. To sort results with files in a/b/c/d/e and all subdirectories first. Then a/b/c/d and subdirectories excluding ones displayed already. And so on. It doesn’t have to be for all directories up to root of project. But something like first three directory levels then the rest of all other files in the project. – SFbay007 Jan 26 '20 at 15:06
  • 1
    I think an outline for a strategy would be to pass the results of `rg` through an algorithm the one used by [promximity-sort](https://github.com/jonhoo/proximity-sort) first. Or, because an external command is being used, you might just be able to modify `counsel-projectile-rg` to pass the results to proximity-sort before showing them to you. – jirassimok Jan 30 '20 at 16:28
  • I didn't know such algorithm exists. I will take a look at that. – SFbay007 Jan 30 '20 at 18:21
  • 1
    It'd be great if the `projectile-sort-order` variable could be set to this. – Peter Becich May 19 '20 at 04:41

0 Answers0