-
Notifications
You must be signed in to change notification settings - Fork 94
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
Initial implementation of a minimap plugin. #39
base: master
Are you sure you want to change the base?
Conversation
andsve
commented
May 22, 2020
- Overloads DocView methods for scrollbar rendering and logic.
- Exposes two global commands, toggling visibility of minimap and toggling syntax highlighting inside the minimap.
- Reloading the minimap module has issues with above mentioned commands.
- Haven't been able to test on any other platform than macOS (with a high dpi backbuffer), but using the SCALE global so should work.
- Overloads DocView methods for scrollbar rendering and logic. - Exposes two global commands, toggling visibility of minimap and toggling syntax highlighting inside the minimap. - Reloading the minimap module has issues with above mentioned commands. - Haven't been able to test on any other platform than macOS (with a high dpi backbuffer), but using the SCALE global so _should work_.
Very cool! Thanks for submitting this. Some initial thoughts after looking through the code and giving it a try
A few places where performance could be improved:
Regarding reloading the module, this isn't something that is strictly meant to be supported by plugins -- the Also might be worth noting that the Additionally, as this is a larger plugin, if you're going to continue working on it would you be happy with creating a github repo for it and linking to that repo from the plugins table (similar to what the |
Good point, planned on doing this but simply forgot, I'll fix!
Ah, of course, I fix!
Very good point, will explore this. 👍
Also good point, I wasn't planning on the plugin ending up this big, but I think it's hard to do any other way. I'll do the above fixes on this branch, but move it to a separate repo once you have given a second feedback review, if you are fine with that? Thanks for the feedback! :) |
That all sounds great! Once the culling is in, is the scrolling behaviour of the minimap something you plan to support too, eg. for cases where the document on the minimap is greater than the height of the minimap? Regarding the rectangle caching, I was thinking something akin to this: local cache = setmetatable({}, { __mode = "k" })
local function get_cached(tokens)
local c = cache[tokens]
if not c then
c = {}
cache[tokens] = c
-- iterate tokens and push [x,width,color] to `c` table
end
return c
end Although [x,width,color] could be stored as a table each, to save memory and possibly improve performance it might make more sense to store them flatly in the table (eg, push first the Since we're using a weak table we never have to worry about cleaning things up, and since we're using the Otherwise great work -- glad to hear you're going to continue working on it! |
Looks great! Looking forward to seeing how it performs with the rectangle caching too, but otherwise it seems like it's basically there. Really nice work. Did you plan on adding a background to it? I wasn't sure if this was something that just wasn't a priority yet or if you were going for a different aesthetic. Thanks for the update! |
Hope you dont mind me chiming in, is the height adjustable? I would prefer being able to set a max height. |
I'll add a background rect, but also an option to disable it. 👍
Should be possible to add this as a option, do you just mean that the minimap should only be visible up to a certain px height? Do you want a scrollbar along with it? Currently this replaces the scrollbar. |
Yes I would still want the scrollbar. The minimap only in the top X pixels. This way my view will stay sleek while still giving me some overview of the file. |
- Added separate logic when scrolling using minimap in large files. - Culls lines outside of minimap (both y and x). - Moved config variables into the config table. - Drawing background rect behind minimap, if config enabled (default: yes).
@andsve two small things I noticed:
|
Works well for me. Is there a chance of adding this plugin to the list of preinstalled ones? |
For long lines I can't get to their very end. This is either using the 'end' key or trying to select a line up to its end: Peek.2021-02-03.15-51.mp4 |
add language_tsx to README