wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.82k stars 266 forks source link

requires couldn't handle nested specification #1000

Closed NamelessDev0000 closed 2 years ago

NamelessDev0000 commented 2 years ago

Features: +acl +iconv +tui See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

- `git --version`: `2.37.1`
- Operating system/version: `arch/rolling`
- Terminal name/version:`alacritty 0.10.1`

### Steps to reproduce

For the following code:

```lua
use {
    'hrsh7th/nvim-cmp',
    config = function()
        require 'plugins.nvim-cmp'
    end,
    requires = {
        {
            'hrsh7th/cmp-nvim-lsp',
            requires = {
                'williamboman/nvim-lsp-installer',
                config = function()
                    require('nvim-lsp-installer').setup()
                end,
                requires = 'nvim-lspconfig',
            },
        },
        {
            'saadparwaiz1/cmp_luasnip',
            requires = 'L3MON4D3/LuaSnip',
        },
        'hrsh7th/cmp-buffer',
        'hrsh7th/cmp-path',
        'hrsh7th/cmp-cmdline',
    }
}

packer couldn't find 'nvim-lspconfig'.

EdenEast commented 2 years ago

The issue here is with the requires for cmp-nvim-lsp. The issue is that you are only passing one table. requires can take either a string or a table. A string is passed for one require and a table for multiple requires. Since you are passing a table requires thinks there is a list of requirements. There is only one that is more complex then just a string.

To resolve this just add an extra table to the requires.

    use {
      'hrsh7th/nvim-cmp',
      config = function()
        print 'nvim-cmp config'
      end,
      requires = {
        {
          'hrsh7th/cmp-nvim-lsp',
          requires = {
            {
              'williamboman/nvim-lsp-installer',
              config = function()
                print 'nvim-lsp-installer config'
              end,
              requires = 'nvim-lspconfig',
            },
          },
        },
        {
          'saadparwaiz1/cmp_luasnip',
          requires = 'L3MON4D3/LuaSnip',
        },
        'hrsh7th/cmp-buffer',
        'hrsh7th/cmp-path',
        'hrsh7th/cmp-cmdline',
      },
    }
NamelessDev0000 commented 2 years ago

The issue here is with the requires for cmp-nvim-lsp. The issue is that you are only passing one table. requires can take either a string or a table. A string is passed for one require and a table for multiple requires. Since you are passing a table requires thinks there is a list of requirements. There is only one that is more complex then just a string.

To resolve this just add an extra table to the requires.

    use {
      'hrsh7th/nvim-cmp',
      config = function()
        print 'nvim-cmp config'
      end,
      requires = {
        {
          'hrsh7th/cmp-nvim-lsp',
          requires = {
            {
              'williamboman/nvim-lsp-installer',
              config = function()
                print 'nvim-lsp-installer config'
              end,
              requires = 'nvim-lspconfig',
            },
          },
        },
        {
          'saadparwaiz1/cmp_luasnip',
          requires = 'L3MON4D3/LuaSnip',
        },
        'hrsh7th/cmp-buffer',
        'hrsh7th/cmp-path',
        'hrsh7th/cmp-cmdline',
      },
    }

Yeah, it's my fault... solved! thx...