You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe what I am doing is misguided, and feel free to tell me, but I am very curious how to solve this problem. Please also tell me if there is a more appropriate way to achieve what I want.
Background: I like to use which-key to set keymaps for (some of) my plugins. An example looks like this.
OK, so I need to define the quickwhichkeyregister function. Where do I do that? Well, along with which-key, of course.
{
"folke/which-key.nvim",
lazy=false,
priority=1001,
init=function()
-- Define this function for convenient use by other plugin configs.quickwhichkeyregister=function(maptable)
require('which-key').register(maptable, { prefix='<leader>' })
endend
}
Notice I have set a very high priority on which-key because I need it to be loaded more or less first.
quickwhichkeyregister is a global variable, so it is now available for other specs to use. And this is true; it works.
Some of the time.
The order of loading appears to be unpredictable, because sometimes when I open neovim I get an error (that the function I am trying to call is nil), and other times I don't.
So:
What am I not understanding (or doing correctly) such that priority=1001 is not causing the init code to be run before the init code of other plugin specs?
Is there an alternative, more idiomatic way to achieve what I am trying to do?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Maybe what I am doing is misguided, and feel free to tell me, but I am very curious how to solve this problem. Please also tell me if there is a more appropriate way to achieve what I want.
Background: I like to use which-key to set keymaps for (some of) my plugins. An example looks like this.
This leads to boilerplate code in several specs, so I tried to improve it as follows:
OK, so I need to define the
quickwhichkeyregister
function. Where do I do that? Well, along withwhich-key
, of course.Notice I have set a very high priority on
which-key
because I need it to be loaded more or less first.quickwhichkeyregister
is a global variable, so it is now available for other specs to use. And this is true; it works.Some of the time.
The order of loading appears to be unpredictable, because sometimes when I open neovim I get an error (that the function I am trying to call is
nil
), and other times I don't.So:
priority=1001
is not causing the init code to be run before the init code of other plugin specs?Thank you :)
Beta Was this translation helpful? Give feedback.
All reactions