Closed stevengubler closed 3 years ago
This means that the hooks (like this one) that include the modules like lsp, git, etc. run after the hook that plug.kak sets up for the powerline module.
Yes, that's intentional.
plug.kak defer powerline_lsp %{
echo "powerline lsp hook"
} condig %{
powerline-start
} defer powerline %{
echo "powerline hook"
}
Will create ModuleLoaded
hooks in this order:
# hooks defined with plug.kak
hook global ModuleLoaded powerline_lsp %{ echo "powerline lsp hook" }
hook global ModuleLoaded powerline %{ echo "powerline hook" }
# hooks defined by loading .kak scripts in powerline.kak repo in pseudo-random order
hook global ModuleLoaded powerline %{ require-module powerline_lsp }
hook global ModuleLoaded powerline %{ require-module powerline_filetype }
# ... rest hooks
Before loading powerline.kak script or any other files in powerline.kak repo. When powerline_lsp.kak
loads, it defines it's own hook for loading powerline
module. After all of that when powerline-start
is called it creates another hook for BufCreate .*
that actually requires the powerline
module, and initiates the sequence for loading everything. So first the echo "powerline lsp module"
is exectued, then echo "powerline"
, then everything that was defined during loading files, and after that the internal powerline-enable
is called, which constructs the powerline from powerline_format
option.
That means that commands like powerline-format will fail and throw errors when in a defer block.
No, that's exactly the opposite :slightly_smiling_face:! Defer block happens after module is loaded, so powerline-format
will not fail. But you might need to keep an eye on defer
order, this is no magic, and you would have to do the same by defining hooks manually. Luckily, in case of this plugin, this is not necessary.
Now to your config. Plug.kak now supports several defer
targets, as I've mentioned above, so you need to put powerline-theme
call inside defer:
plug "andreyorst/powerline.kak" defer "powerline" %{
set-option global powerline_format 'lsp'
# or powerline-format global 'lsp'
} defer powerline_tomorrow_night %{
powerline-theme tomorrow-night
} config %{
powerline-start
}
This works on my end without errors. As for powerline.kak: Warning, trying to load non-existing module 'lsp'
This is because the module was not yet loaded (and I'm not sure why, really), but it will be loaded eventually. With the config above I have the following modeline:
Although lsp
module should declare variables for errors and warnings, as if kak-lsp is not loaded they don't exist and this is a problem.
docs are now updated to mention this. Closing
Problem description
powerline.kak
's configuration isn't compatible with the new changes toandreyorst/plug.kak
.Steps to reproduce
andreyorst/plug.kak
. (current as of writing)plug.kak
like so:kak -e 'b *debug*'
to open an new instance of kakoune and show the debug buffer.What should happen
When configuring a standard installation of
powerline.kak
in the way theREADME.md
indicates (by usingplug.kak
and it'sdefer
feature, it should apply configurations correctly and not throw errors.What happens instead
Powerline is just using the default configuration, and the configurations in the
defer
block did not apply. The debug buffer showsEnvironment information
Kakoune version:
Kakoune v2020.09.01
OS version: MacOS 11.2.2sh
executable version:zsh 5.8
My thoughts
This appears to stem from a new change to
plug.kak
's defer block:source:
plug.kak
's READMEThis means that the hooks (like this one) that include the modules like
lsp
,git
, etc. run after the hook thatplug.kak
sets up for thepowerline
module.That means that commands like
powerline-format
will fail and throw errors when in adefer
block.My workaround
To get around this issue, we can manually require all of the modules we need in our
defer
block:However, this isn't a great user experience; it greatly increases the complexity of configuring powerline. In my particular configuration, it also increased kakoune's startup time by 2x, from
~0.23s
to~0.45s
(as measured bytime kak -e 'q'
).powerline.kak
already had a relatively large impact on startup time, so a further doubling makes it significantly worse.