Closed jla2000 closed 2 months ago
hey π
thanks for reporting. I'm travelling right now, but will have a look when I'm near my laptop again.
Hey again.
I just tried to reproduce it (using rocks.nvim and onedarkpro.nvim, because onedark.nvim wasn't on luarocks yet)
and was not able to reproduce the error with your snippet. It called the after
script and set the colorscheme.
It looks like you're using Nix. Could you please provide a minimal reproducible config? Ideally, with a flake that I can build from.
Hey, thanks for your time :) I will try to set something up this weekend
Put the following into a default.nix
:
{ pkgs ? import <nixpkgs> { } }:
pkgs.neovim.override {
configure = {
customRC = /* lua */ ''
lua << EOF
require("lz.n").load({
{
"onedark.nvim",
colorscheme = "onedark",
},
{
"xyz",
event = "UIEnter",
after = function()
vim.cmd.colorscheme("onedark")
end,
}
})
EOF
'';
packages.all = with pkgs.vimPlugins; {
start = [ lz-n ];
opt = [ onedark-nvim ];
};
};
}
And then:
$ nix-build
$ ./result/bin/nvim
When just not having the "xyz" entry here, everything works as expected. But within the after script of this entry it will break
lz.n relies on :h ColorSchemePre
autocommands to lazy-load plugins on colorscheme events.
To debug your setup, I've created the follwing init.lua
local test = false
vim.api.nvim_create_autocmd("ColorSchemePre", {
callback = function()
test = true
end,
})
vim.api.nvim_create_autocmd("UIEnter", {
callback = function()
pcall(vim.cmd.colorscheme, "onedark")
if not test then
error("ColorSchemePre was not invoked")
end
end,
})
And ran it with nvim -u NORC -u init.lua
.
It fails, indicating that Neovim did not invoke a ColorSchemePre
event when calling vim.cmd.colorscheme
.
I don't know if this is a Neovim bug or intended behaviour, but I will open a Neovim issue.
Closing, as there is nothing I can do to work around that in lz.n.
Reopening (see comment on the Neovim issue).
Will have to make sure nested=true
doesn't break anything and add a test cases (when I'm near my laptop).
Thanks for taking the time and fixing it π
I'm working on a plugin that persists colorschemes, and I found the following issue:
This code does not work in this combination:
Somehow it's not possible to load the colorscheme inside the after function, or also if the plugin xyz e.g. tries to load it in its own code.
When just calling
vim.cmd.colorschem("onedark")
without the xyz plugin, it will work correctly.