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

Fix firenvim and LeaderF build issues #289

Merged
merged 1 commit into from
Aug 2, 2024
Merged

Fix firenvim and LeaderF build issues #289

merged 1 commit into from
Aug 2, 2024

Conversation

jdhao
Copy link
Owner

@jdhao jdhao commented Aug 2, 2024

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 neovim/neovim#29957.

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 neovim/neovim#29957.
@jdhao jdhao merged commit beec97c into main Aug 2, 2024
@jdhao jdhao deleted the fix-plugin-build branch August 2, 2024 15:38
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