Skip to content

fix: prevent premature loading of which-key.nvim - #198

Open
bbnolauv wants to merge 1 commit into
m4xshen:mainfrom
bbnolauv:fix/whichkey
Open

fix: prevent premature loading of which-key.nvim#198
bbnolauv wants to merge 1 commit into
m4xshen:mainfrom
bbnolauv:fix/whichkey

Conversation

@bbnolauv

Copy link
Copy Markdown

Problem

The recent fix #155 introduced pcall(require, "which-key.state"). However, when using package managers like lazy.nvim, calling require on a lazy-loaded plugin's module will immediately force-load the plugin on the very first keystroke, bypassing any user-defined lazy-loading configurations (e.g. cmd, keys, or event for which-key).

Solution

Instead of directly calling require, check package.loaded["which-key.state"] ~= nil first.

This prevents lazy.nvim's global require hook from intercepting the call and loading the plugin prematurely. If which-key is already loaded, we then safely perform the require as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant