Skip to content

How to ensure packer.startup runs before require("package")? #651

Answered by wbthomason
steve-lorimer asked this question in Q&A
Discussion options

You must be logged in to vote

This is due to the order in which (Neo)vim sources files at startup.

packer, by default, outputs its loader code to plugin/packer_compiled.lua. This code includes the setup necessary for the module lazy-loader to work. The files in plugin/ are all automatically sourced during startup, but after your init.lua runs - so, your require fails.

There's a long-standing plan to move sourcing of the lazy-loaders to the very start of the startup process, but, until I have time to implement that large change, you have two options for workarounds:

  1. Put your require('keybindings') in a file that runs after plugin/packer_compiled.lua, e.g. plugin/x_keybindings.lua or similar (ordering is lexicographic).

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by steve-lorimer
Comment options

You must be logged in to vote
2 replies
@wbthomason
Comment options

@steve-lorimer
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants