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

feature: Don't process dependencies if spec is disabled #868

Closed
1 task done
UtkarshVerma opened this issue Jun 11, 2023 · 3 comments · Fixed by #1058
Closed
1 task done

feature: Don't process dependencies if spec is disabled #868

UtkarshVerma opened this issue Jun 11, 2023 · 3 comments · Fixed by #1058
Labels
enhancement New feature or request

Comments

@UtkarshVerma
Copy link

Did you check the docs?

  • I have read all the lazy.nvim docs

Is your feature request related to a problem? Please describe.

I am organizing my plugin spec based on the feature they implement. For example, completion.lua has the following snippet:

  {
    "hrsh7th/cmp-nvim-lsp",
    dependencies = {
      {
        "nvim-lspconfig",
        opts = function(_, opts)
          return vim.tbl_deep_extend("force", opts, {
            capabilities = require("cmp_nvim_lsp").default_capabilities(),
          })
        end,
      },
    },
  }

If, for some reason, I wanted to disable this specific spec, I can do it through enabled = false. However, even when I disable the spec, lazy still tries to process the dependencies and tries to initialize nvm-lspconfig with cmp-nvim-lsp. This fails because the plugin has not been loaded.

/home/subaru/.config/nvim/lua/plugins/completion.lua:24: module 'cmp_nvim_lsp' not found:
	no field package.preload['cmp_nvim_lsp']
cache_loader: module cmp_nvim_lsp not found
cache_loader_lib: module cmp_nvim_lsp not found
	no file './cmp_nvim_lsp.lua'
	no file '/usr/share/luajit-2.1.0-beta3/cmp_nvim_lsp.lua'
	no file '/usr/local/share/lua/5.1/cmp_nvim_lsp.lua'
	no file '/usr/local/share/lua/5.1/cmp_nvim_lsp/init.lua'
	no file '/usr/share/lua/5.1/cmp_nvim_lsp.lua'
	no file '/usr/share/lua/5.1/cmp_nvim_lsp/init.lua'
	no file './cmp_nvim_lsp.so'
	no file '/usr/local/lib/lua/5.1/cmp_nvim_lsp.so'
	no file '/usr/lib/lua/5.1/cmp_nvim_lsp.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'

# stacktrace:
  - ~/.config/nvim/lua/plugins/completion.lua:24 _in_ **values**
  - vim/_editor.lua:0 _in_ **cmd**
  - /persistence.nvim/lua/persistence/init.lua:57 _in_ **load**
  - lua/:1
  - vim/_editor.lua:0 _in_ **cmd**
  - /dashboard-nvim/lua/dashboard/theme/doom.lua:23

Describe the solution you'd like

If any spec has enabled = false set, then lazy should completely ignore all config associated with it, including the dependencies.

Describe alternatives you've considered

N/A

Additional context

No response

@UtkarshVerma UtkarshVerma added the enhancement New feature or request label Jun 11, 2023
@AlexMasterov
Copy link

The same problem with the keys property. Plugin is disabled but its key mappings are loaded.

@folke
Copy link
Owner

folke commented Jun 19, 2023

@AlexMasterov that's not correct. When using cond then yes, that's on purpose, but not when enabled=false

@folke
Copy link
Owner

folke commented Jun 19, 2023

As for OP's issue, that's how dependencies work.

Dependencies just specify what deps need to be loaded when the plugin loads.
It does not do anything special to the specs of the dependencies.

Specs get merged to one spec per plugin.

As long as a plugin is not disabled, it will be loaded.

Merging part of a spec only when the dependent is enabled is not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants