Vim-plug: Feature Request: Lua functions for Neovim users

Created on 28 Nov 2019  路  2Comments  路  Source: junegunn/vim-plug

Vimscript is great for configuration, but in Neovim, Lua is becoming more of an attractive choice (at least IMO) for configuration, such that I'm switching my init.vim over as much as I can to an init.lua. While doing this, I've noticed that there isn't a simple and easy-to-use Lua equivalent to the Vimscript functions plug#start(), Plug 'foo' and plug#end(). How feasible would it be to add these Lua functions for Neovim users?

Example functions which could be added: plug_start(), plug(), and plug_end(). However, it would be nice to be able to call plug() once, giving it a Lua table containing each plugin name. Then plug_start() and plug_end() wouldn't be necessary: just the (potential?) requirement of only calling plug() once.


  • Type:

    • [ ] Bug

    • [ ] Enhancement

    • [x] Feature Request

    • [ ] Question

  • OS:

    • [ ] All/Other

    • [x] Linux

    • [ ] OS X

    • [ ] Windows

  • Vim:

    • [ ] Terminal Vim

    • [ ] GVim

    • [x] Neovim

neovim wontfix

Most helpful comment

So, after some discussion on neovim's gitter @norcalli came up with this implementation:

local vim = vim
local function plug(path, config)
  vim.validate {
    path = {path, 's'};
    config = {config, vim.tbl_islist, 'an array of packages'};
  }
  vim.fn["plug#begin"](path)
  for _, v in ipairs(config) do
    if type(v) == 'string' then
      vim.fn["plug#"](v)
    elseif type(v) == 'table' then
      local p = v[1]
      assert(p, 'Must specify package as first index.')
      v[1] = nil
      vim.fn["plug#"](p, v)
      v[1] = p
    end
  end
  vim.fn["plug#end"]()
end

-- Example usageplug {'julia', { g = {default_julia_version = '1.1'} }}
plug('~/.config/nvim/plugged', {
  'norcalli/nvim-colorizer.lua';
  {'Peeja/vim-cdo'; on = {'Cdo', 'Ldo'} };
})

@norcalli Also mentioned some possible additions, like adding a g = {} option for setting globals (e.g. plug {'julia', { g = {default_julia_version = '1.1'} }} and a disabled flag.

Nice thing is that all of this could be added to plug.vim via a lua block, like so:

lua << EOF
-- Lua code goes here
EOF

@junegunn What do you think?

All 2 comments

So, after some discussion on neovim's gitter @norcalli came up with this implementation:

local vim = vim
local function plug(path, config)
  vim.validate {
    path = {path, 's'};
    config = {config, vim.tbl_islist, 'an array of packages'};
  }
  vim.fn["plug#begin"](path)
  for _, v in ipairs(config) do
    if type(v) == 'string' then
      vim.fn["plug#"](v)
    elseif type(v) == 'table' then
      local p = v[1]
      assert(p, 'Must specify package as first index.')
      v[1] = nil
      vim.fn["plug#"](p, v)
      v[1] = p
    end
  end
  vim.fn["plug#end"]()
end

-- Example usageplug {'julia', { g = {default_julia_version = '1.1'} }}
plug('~/.config/nvim/plugged', {
  'norcalli/nvim-colorizer.lua';
  {'Peeja/vim-cdo'; on = {'Cdo', 'Ldo'} };
})

@norcalli Also mentioned some possible additions, like adding a g = {} option for setting globals (e.g. plug {'julia', { g = {default_julia_version = '1.1'} }} and a disabled flag.

Nice thing is that all of this could be added to plug.vim via a lua block, like so:

lua << EOF
-- Lua code goes here
EOF

@junegunn What do you think?

Hi, I don't see myself using it anytime soon so I'm not interested in maintaining it in this project (implementing it, adding tests for it, documenting it, answering questions and responding to feature requests about it, etc).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

santosh picture santosh  路  4Comments

Mryehua picture Mryehua  路  4Comments

meain picture meain  路  3Comments

orao picture orao  路  3Comments

fvictorio picture fvictorio  路  3Comments