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

bug: custom plugin rtp docs don't work #1319

Closed
3 tasks done
strager opened this issue Feb 10, 2024 · 3 comments
Closed
3 tasks done

bug: custom plugin rtp docs don't work #1319

strager opened this issue Feb 10, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@strager
Copy link

strager commented Feb 10, 2024

Did you check docs and existing issues?

  • I have read all the lazy.nvim docs
  • I have searched the existing issues of lazy.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

v0.9.5

Operating system/version

macOS 14.2.1

Describe the bug

A plugin exists inside a Git repo. The plugin isn't at the root of the Git repo; it's in the plugin/vim/quick-lint-js.vim subdirectory.

Following the docs, it looks like I should use the config hook: https://github.com/folke/lazy.nvim/tree/main?tab=readme-ov-file#-migration-guide

However, the config hook executed after the Git repo is added to runtimepath and after lazy.nvim executes files in the Git repo which don't belong to the plugin (!).

Steps To Reproduce

Create ~/.config/nvim/lua/plugins/quick-lint-js.lua:

return {
  "quick-lint/quick-lint-js",
  tag = "3.1.0",
  config = function(plugin)
    vim.opt.rtp:append(plugin.dir .. "/plugin/vim/quick-lint-js.vim")

    require("lspconfig/quick_lint_js").setup {}
  end
}

Open Neovim. Observe that Neovim exits on startup because lazy.nvim executes <quick-lint-js>/plugin/vim/test.vim which is outside the Vim plugin's directory (<quick-lint-js>/plugin/vim/quick-lint-js.vim).

Expected Behavior

Neovim doesn't exit on startup. The quick-lint-js plugin is loaded without error like in other package managers which support an rtp option.

Repro

No response

@strager strager added the bug Something isn't working label Feb 10, 2024
@strager
Copy link
Author

strager commented Feb 10, 2024

Related issues: #183, #756, #1262

@strager
Copy link
Author

strager commented Feb 10, 2024

I found a hacky workaround. The cond hook executes before anything is added to runtimepath, so I can edit plugin.dir in a cond hook to get the behavior I want:

return {
  "quick-lint/quick-lint-js",
  tag = "3.1.0",
  cond = function(plugin)
    -- TODO(strager): Don't make this happen multiple times.
    plugin.dir = plugin.dir .. "/plugin/vim/quick-lint-js.vim"
    return true
  end,
  config = function(_plugin)
    require("lspconfig/quick_lint_js").setup {}
  end,
}

(This workaround probably breaks upgrading and some other flows. I haven't tested it well.)

@strager
Copy link
Author

strager commented Feb 10, 2024

@folke Would you accept a patch to fix this bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants