Skip to content

Add Lua version of the script to autoinstall missing plugins #1336

Description

@ac1dTigR

Description

I propose that this code snippet be added to the Tips page on the wiki:

-- Run PlugInstall if there are missing plugins
vim.api.nvim_create_autocmd("VimEnter", {
  callback = function()
    local plugs = vim.g.plugs or {}
    for _, plug in pairs(plugs) do
      if vim.fn.isdirectory(plug.dir) == 0 then
        vim.cmd("PlugInstall --sync")
        vim.cmd("source $MYVIMRC")
        break
      end
    end
  end,
})

Note: the code was generated by ChatGPT (https://chatgpt.com/s/t_6a51a66c67fc8191a0037a87aa6e7ad3) and tested by me.

Plug block

:version

NVIM v0.12.2
Build type: RelWithDebInfo
LuaJIT 2.1.1774896198

Type

  • Bug
  • Enhancement
  • Feature Request
  • Question

OS

  • All/Other
  • Linux
  • macOS
  • Windows

Vim

  • Terminal Vim
  • GVim
  • Neovim

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions