andreyorst / powerline.kak

Kakoune modeline, but with passion
MIT License
50 stars 8 forks source link

[Feature Proposal] Dynamically remove modules to fit in the window #28

Open adrusi opened 2 years ago

adrusi commented 2 years ago

I've added some logic to remove modules from the powerline on a per-buffer basis when it would otherwise overflow the window. Happy to submit a pull request if you think it's in scope for the project.

https://gist.github.com/adrusi/5ec619d06ebe55746bb49422071a7206

andreyorst commented 2 years ago

This would be a great addition!

I wanted to add this but was concerned with performance. How does your implementation handle window tracking? I guess you can submit a patch, so I could read the code, and see how it works on my phone, where both the screen size and performance are limited

adrusi commented 2 years ago

The link gist has the code. Placing the .inc.sh files in your path and loading the .kak file at startup should let you set the powerline_module_priority option and see it in action.

Not sure exactly what you mean by window tracking, but the tricky part re: performance is that hooks that indicate the powerline should be resized tend to fire in big clusters and the resize logic is a bit expensive, so I have some concurrency logic to wait until the hooks stop firing for a specified interval before attempting to do anything. That part of the code is probably more awkward than it needs to be since I don't understand kakoune's runtime quite that well and it's annoying to debug so it's rather defensive.

There's some performance left on the table, especially because my current implementation doesn't patch powerline.kak at all, I'll rework it as a patch sometime in the next week or so and see if there's any improvements. No performance issues on my laptop, but it's fairly powerful and I haven't tested elsewhere.