Projectile's author here.
Some examples of the nature of the problem would be useful, as I don't quite understand if we're talking about exactly the same files appearing at different places of the repo or it's files with the name that are actually different.
Projectile returns the project files relative to the project root, so it's pretty easy to tell apart files in the second case, but I'm assuming your problem is probably the first case. I'm not aware of any existing sort order based on the distance from the current folder, although I can imagine this shouldn't very hard to implement.
At any rate - projectile's quite flexible when it comes both to indexing strategies and to sorting orders, so it will definitely be possible to use something custom there, if the built-in options don't work well for you.
I work on a large corporate mono-repo in which numerous
filenames occur repeatedly. Further, various directories
above such duplicates also have duplicated names.
Currently I use a self-built emacs tool to index this space:
* Build a map from a unique filename to a set of
repo-relative directory paths to files with that name
* Compute a disambiguation string for completing reads
for unique filenames this string is empty; otherwise:
* Repeatedly strip identical leading directories
* Repeatedly strip identical trailing directories
I would like to replace this tool with something like
project.el or projectile.el. So the first question is does
either package do anything intelligent when filenames
are duplicated? If so, what?
Then, is there any completion package that can present
the candidates in an order reflecting their distance from
the current buffer's working directory? My thought is to
sort identically named candidates by their repo-relative
paths. A focused, incrementally widening presentation
of candidates would show initially those in or below the
current working directory. Each time instructed to widen
the presentation it would advance up the parent directory
chain, showing candidates in or below that directory.
/john