Open khughitt opened 10 years ago
I like the idea, and it's indeed quite easy to do (as you say, by subsampling), but since the graphical resolution of the minimap is quite limited (we are in a console, after all!), I'm not sure how useful this may end to be: the important visual cues that help getting a birdview of a document are mainly the homogeneous blocks and the 'outliers' (either very short lines or very long lines in the middle of other lines). By subsampling, I fear that many of those cues will disappear. Also, a naive subsampling approach ('take 1 out of X lines') does not work: if you add one line in the middle of your document, the whole layout of the minimap will change.
Do you have in mind a sensible algorithm that would achieve what you are looking for?
That's a good point. Unfortunately, I don't know of any really great ways around the issue. One possibility might be to use something like a kernel density estimate to get a smoothed view of all of the lines, and sample at regular intervals along it. Adding any single like then should not have any drastic effects on the shape of the KDE, at least not when there are sufficient lines in the file. The down-side of this approach is that you may also end up smoothing out some of the outliers which, as you suggest, also provide useful context.
As far as the motivation, I think it still could be useful as something of a nicer version of the scrollbar. Out of all the things I miss in console vim, the most unexpected one is a scrollbar. Even though I hardly would use it, just having something that at a glace tells me location and scale in the document is really helpful.
Kernel density estimate is an interesting idea, thanks for the link ( here a comparison of various implementations in python). I may play a little bit with it: I don't know if a dependency on scipy is desirable, and I also need to check how fast it is (since we basically redraw after each keystroke!)
Yea, I was also thinking it might be a bit overkill as a requirement.
Performance-wise, I think the size of the data is small enough that it shouldn't be an issue.
Rough example:
[1]: import numpy
In [2]: from scipy.stats import gaussian_kde
In [3]: line_lengths = numpy.random.randint(100, size=1000)
In [4]: %timeit gaussian_kde(line_lengths)
1000 loops, best of 3: 165 µs per loop
Would it be possible to include an option to have vim-minimap always display a mininav for the full document? This would provide some very useful context.
If the document is very long, you could probably just subsample the lines in the file and generate the mininav based on that (if that is not what you are already doing...)