Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: ability to continue loading other plugins when one fails #349

Closed
1 task done
axieax opened this issue Jan 8, 2023 · 12 comments · Fixed by #376
Closed
1 task done

feature: ability to continue loading other plugins when one fails #349

axieax opened this issue Jan 8, 2023 · 12 comments · Fixed by #376
Labels
enhancement New feature or request

Comments

@axieax
Copy link

axieax commented Jan 8, 2023

Did you check the docs?

  • I have read all the lazy.nvim docs

Is your feature request related to a problem? Please describe.

When a plugin's config errors out, other plugins may not be loaded. As such, users are unable to use the benefits of other plugins to resolve config issues with that plugin(s).

Describe the solution you'd like

Warn or display the error and which plugin it's from, and continue loading the other plugins. I've done something similar before for packer.nvim using protected calls and it resolves this issue completely: https://github.com/axieax/dotconfig/blob/28f46b2353e5496e666c4a5a9d26ee4c30fe1cbf/nvim/lua/axie/plugins/packer.lua#L46-L52

Describe alternatives you've considered

Using an alternative text editor to resolve minor config issues in the case of an infinite loop

Additional context

No response

@axieax axieax added the enhancement New feature or request label Jan 8, 2023
@folke
Copy link
Owner

folke commented Jan 8, 2023

This is already the case? If you still encounter issues with this, please provide an example where config if plugin prevents loading of other plugins.

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Jan 8, 2023
@axieax
Copy link
Author

axieax commented Jan 8, 2023

It's related to issue #348, where an error with project.nvim due to the setup loader will prevent my barbar bufferline from being loaded if I click <Esc> or q to skip the warning message. However, if I click <CR> to "accept" the message, barbar loads fine, not sure why. I find this is also the case with having a huge print before lazy loads plugins (e.g. with print(string.rep("-", 10000)). I have both lazy-loaded, and barbar on event: VeryLazy.

@folke
Copy link
Owner

folke commented Jan 8, 2023

Thats just standard Neovim behavior with vim.notify. vim.notify shows the warning/error that something went wrong. If you do q or esc there, then Neovim will abort the code (same as if you would press <c-c>). Nothing I can do about that.

@axieax
Copy link
Author

axieax commented Jan 8, 2023

Ahh I see. Sorry for the confusion and thanks for the help!

@axieax
Copy link
Author

axieax commented Jan 13, 2023

Update: it seems when the error isn't from the config function itself, but from a lazy-issued spec check, other plugins don't get loaded. For example, the following error disables my dressing.nvim loading (VeryLazy).

Error executing vim.schedule lua callback: .../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:146: Vim(append):Error executing lua callback: v
im/_meta.lua:0: Vim:Lua module not found for config of barbar.nvim. Please use a `config()` function instead
stack traceback:
        [C]: in function 'nvim_set_option_value'
        vim/_meta.lua: in function '_set'
        vim/_meta.lua: in function '__newindex'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:358: in function 'add_to_rtp'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:214: in function '_load'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:178: in function 'load'
        ...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:33: in function <...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:26>
        [C]: in function 'cmd'
        .../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:146: in function ''
        vim/_editor.lua: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
stack traceback:
        [C]: in function 'cmd'
        .../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:146: in function ''
        vim/_editor.lua: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

@axieax
Copy link
Author

axieax commented Jan 13, 2023

p.s. also on that note, not sure why barbar.nvim's lua module of "bufferline" doesn't get detected.

@folke folke reopened this Jan 13, 2023
@folke
Copy link
Owner

folke commented Jan 13, 2023

Can you provide a minimal init.lua? I can't reproduce this.

Bufferline doesn't get detected because there's both a bufferline directory and a bufferline.lua. I can fix this, but still would like to know what is causing the failure apart from that.

What do you mean eactly with a lazy-issued spec check?

What you are seeing is just a vim.notify so again, other plugins would still be loaded. Unless you press <q> when you see that message, then Neovim will interrupt all lua code.

@folke
Copy link
Owner

folke commented Jan 13, 2023

I get this when adding barbar:
image

There's no stack trace for me

@folke
Copy link
Owner

folke commented Jan 13, 2023

That stacktrace is also super weird. It doen't really make sense. Seems related to LazyVim/starter#5 somehow. I see a similar stacktrace there

@folke
Copy link
Owner

folke commented Jan 13, 2023

I can reproduce that stacktrace. Checking what's wrong here. Super weird

@folke
Copy link
Owner

folke commented Jan 13, 2023

I was able to fix the weird error. It was triggered becuase I did vim.cmd[[do VeryLazy]]. Somehow that makes vim.notify behave very odd.

The fix was to use vim.api.nvim_exec_autocmds instead, which does not result in that weird stacktrace.

Lazy now also correctly de-duplicates plugin mods, so the config() will run fine now without a custom function.

@axieax
Copy link
Author

axieax commented Jan 13, 2023

Perfect thank you so much for the painful debugging and the fix! Appreciate it a lot 🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants