andreyorst / powerline.kak

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

Fails to display with autoload installation #24

Closed bound-variable closed 2 years ago

bound-variable commented 2 years ago

Problem description

Powerline fails to display

Steps to reproduce

  1. Clone the repo into /autoload: git clone https://github.com/andreyorst/powerline.kak
  2. Run Kakoune
  3. Although the README for autoloading doesn't specify any more steps, I see the option to run powerline-start and tried it.

What should happen

Powerline appears

What happens instead

Nothing

Environment information

Kakoune version: 2021.11.08-1 OS version: Arch sh executable version: sh is linked to bash, version 5.1.016-1

andreyorst commented 2 years ago

I've never used autoload and I actually don't understand how it works, since I've created and started plug.kak from day one of me using Kakoune. Maybe it requires some more steps, but in my understanding of it, it should work as if you've sourced everything manually, and from that point it doesn't differ from initialization with plug.kak. If you'll figure out what causes the issue, please report back, so I could add it to the readme.

bound-variable commented 2 years ago

I just tried the "by hand" method. Now when I run Kakoune, I no longer have the command powerline-start. With autoloading, at least the command was there.

andreyorst commented 2 years ago

are you sure you've loaded the rc/powerline.kak script? It defines this command at the very top, so if it's not defined, it means it wasn't loaded.

andreyorst commented 2 years ago

OK, It seems I've figured it out. It works, it just didn't render. For some reason it only appears when opening new buffers. I enable powerline before window is set up in my config, so perhaps this is why I never noticed this behavior

andreyorst commented 2 years ago

So, you can use autoload as you were, you just need to call powerline-start in your config, and not interactively, for it to appear in the first opened buffer.

bound-variable commented 2 years ago

Wonderful. It works now. Shall I close this issue?

andreyorst commented 2 years ago

I'll investigate more on why this doesn't call refres after calling this command. IIRC there were some issues with that so I've removed it. Once I'm certain, I'll either update the readme to be more explicit, or add a refresh and then I'll close this. For now, let's leave it open :)

andreyorst commented 2 years ago

I think I've remembered why this was made how it is -- the powerline-start command can't refresh the modeline, because when it's ran from the kakrc during load there's no window context, and it will not be able to do anything, as all of the variables are window scoped. Because of that it registers a hook:

https://github.com/andreyorst/powerline.kak/blob/c5ef9a845bbd886c73ef00c0efff986e02d5f5d8/rc/powerline.kak#L15-L22

And when this hook activates it redraws the powerline for all opened buffers. So powerline-start only makes sense as a command to call from kakrc. If you need to manually enable powerline you can call powerline-enable but this requires a powerline module to be loaded, which is also done in the powerline-start command, and that explains why other commands weren't available, as the hook wasn't triggered and module was never loaded.

TL;DR:

Use powerline-start from kakrc. Use require-module powerline and powerline-enable interactively.