mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
In lazy.nvim, the `build` parameter accept value in different format. If the value is 1. a string and starts with `:`, it will be treated as vim command 2. a string and starts without `:`, it will be treated as shell command 3. a function. Lazy.nvim will run this function I compared closely between case 1 and case 3. In case 1, when lazy.nvim runs the viml command, the runtimepath is already populated with the current plugin we are trying to build. However in case 3, the runtimepath is not populated with the plugin path, which means that any command you run by this plugin is not available. So I did it in a hacky way to add the plugin path to runtimepath manually, and source it manually using `:runtime` command. The `: runtime` command is needed because in the init process, adding the plugin path to runtimepath does not ensure that the script under this plugin is sourced immediately. So if we want to use the command/function immediately, we need to source it manually, see also https://github.com/neovim/neovim/issues/29957.