NTBBloodbath / cheovim

Neovim configuration switcher written in Lua. Inspired by chemacs.
GNU General Public License v2.0
332 stars 13 forks source link

Problem switching between lunarvim and glepnir configurations #1

Open rebuilt opened 3 years ago

rebuilt commented 3 years ago

Hello. Thank you for your plugin. It's exactly what I've been looking for. I frequently switch between lunarvim and glepnir configurations.

Lunarvim creates a '~/.local/share/nvim/site/lua/_compiled.lua' file. The glepnir config sees the packer compile file created by lunarvim and tries to use it. It therefore fails to load its plugins correctly. It only breaks in one direction: Lunarvim -> glepnir. Not the other way around. The compiled file must be removed in order to correctly switch to the glepnir configuration. I then have to run :PackerSync each time I switch over to the glepnir config.

This is not strictly a cheovim problem since it happens when switching between the two configurations manually as well.

I don't think I know enough about packer to understand why this happens with the compile file. Is there a way to have a smoother transition between these two configs?

vhyrro commented 3 years ago

Wow, that's certainly an oddity we overlooked. I believe our best bet is to manage that directory with symlinks, similarly to how we do it with other directories and files in cheovim. That way lunarvim's compiled.lua file will stay isolated from the rest of the configurations. What on earth is that file even doing there? That's like the worst place to put it, idk what the design choice behind that one is lol. We'll get to work on the fixes though!

rebuilt commented 3 years ago

That file is normally found in ~/.config/nvim/plugin/_compiled.lua. But when using cheovim it gets placed in ~/.local/share/nvim/site/lua/_compiled.lua. But it's location is kind of irrelevant. It's existence at either location breaks glepnir.

NTBBloodbath commented 3 years ago

Hey, after installing LunarVim to try to reproduce it I've noticed that LunarVim isn't the cause of this problem. It's caused due to glepnir setup, you can see for yourself in pack.lua#L6 and global.lua#L15.

It seems that glepnir has some own Packer implementation. I'll see what I can do

rebuilt commented 3 years ago

Thanks, I appreciate it very much.

vhyrro commented 3 years ago

Alright, this problem is really, really tough. After a few days of thinking and testing out failed ideas I may have come to a solution - however it won't work as perfectly as one might expect.

Glepnir's configuration, is - well - special, to put it nicely. There are several things that do not conform to the standards you might expect from a regular Neovim config. Glepnir's config is certainly not the only special one out there, and creating a fix simply for his configuration and not all the others will prove to be a ginormous pain. So, the solution is very simple, albeit flexible. Cheovim will gain support for more callbacks. This will allow you to conditionally execute your own code to remove e.g. excess files on the filesystem before a new configuration gets loaded. That way, you will be able to write a small bit of code so things like glepnir's own compiled.lua file gets removed before the switch, and therefore removes any errors. I'm sorry that we can't provide a more "easy" solution, however it would seriously make life pain.

I'll begin fleshing out the feature tomorrow when I have the time, if I have some sort of euphoric realization during that period regarding this issue I will let you know! If you have any of your own ideas, let me know too.

rebuilt commented 3 years ago

Thank you for your help. Will the callback be executed each time neovim is launched or only after a configuration switch?

I should also mention I tried out this config as well, and it seems to be based on the glepnir config, so it will also have the same packer quirks.

vhyrro commented 3 years ago

The callbacks will only execute whenever a configuration switch happens, having a bit of code run every time would slow down the startup time of the configuration, which cheovim does not want to do. Thanks for mentioning that lvim config, I'll look into it as well for the fun of it.