Git Product home page Git Product logo

packer.nvim's Introduction

NOTICE:

This repository is currently unmaintained. For the time being (as of August, 2023), it is recommended to use one of the following plugin managers instead:

  • lazy.nvim: Most stable and maintained plugin manager for Nvim.
  • pckr.nvim: Spiritual successor of packer.nvim. Functional but not as stable as lazy.nvim.

packer.nvim

Gitter

use-package inspired plugin/package management for Neovim.

Have questions? Start a discussion.

Have a problem or idea? Make an issue or a PR.

Packer is built on native packages. You may wish to read :h packages before continuing

Table of Contents

  1. Features
  2. Requirements
  3. Quickstart
  4. Bootstrapping
  5. Usage
    1. The startup function
    2. Custom Initialization
    3. Specifying Plugins
    4. Performing plugin management operations
    5. Extending packer
    6. Compiling Lazy-Loaders
    7. User autocommands
    8. Using a floating window
  6. Profiling
  7. Debugging
  8. Compatibility and known issues
  9. Contributors

Features

  • Declarative plugin specification
  • Support for dependencies
  • Support for Luarocks dependencies
  • Expressive configuration and lazy-loading options
  • Automatically compiles efficient lazy-loading code to improve startup time
  • Uses native packages
  • Extensible
  • Written in Lua, configured in Lua
  • Post-install/update hooks
  • Uses jobs for async installation
  • Support for git tags, branches, revisions, submodules
  • Support for local plugins

Requirements

  • You need to be running Neovim v0.5.0+
  • If you are on Windows 10, you need developer mode enabled in order to use local plugins (creating symbolic links requires admin privileges on Windows - credit to @TimUntersberger for this note)

Quickstart

To get started, first clone this repository to somewhere on your packpath, e.g.:

Unix, Linux Installation

git clone --depth 1 https://github.com/wbthomason/packer.nvim\
 ~/.local/share/nvim/site/pack/packer/start/packer.nvim

If you use Arch Linux, there is also an AUR package.

Windows Powershell Installation

git clone https://github.com/wbthomason/packer.nvim "$env:LOCALAPPDATA\nvim-data\site\pack\packer\start\packer.nvim"

Then you can write your plugin specification in Lua, e.g. (in ~/.config/nvim/lua/plugins.lua):

-- This file can be loaded by calling `lua require('plugins')` from your init.vim

-- Only required if you have packer configured as `opt`
vim.cmd [[packadd packer.nvim]]

return require('packer').startup(function(use)
  -- Packer can manage itself
  use 'wbthomason/packer.nvim'

  -- Simple plugins can be specified as strings
  use 'rstacruz/vim-closer'

  -- Lazy loading:
  -- Load on specific commands
  use {'tpope/vim-dispatch', opt = true, cmd = {'Dispatch', 'Make', 'Focus', 'Start'}}

  -- Load on an autocommand event
  use {'andymass/vim-matchup', event = 'VimEnter'}

  -- Load on a combination of conditions: specific filetypes or commands
  -- Also run code after load (see the "config" key)
  use {
    'w0rp/ale',
    ft = {'sh', 'zsh', 'bash', 'c', 'cpp', 'cmake', 'html', 'markdown', 'racket', 'vim', 'tex'},
    cmd = 'ALEEnable',
    config = 'vim.cmd[[ALEEnable]]'
  }

  -- Plugins can have dependencies on other plugins
  use {
    'haorenW1025/completion-nvim',
    opt = true,
    requires = {{'hrsh7th/vim-vsnip', opt = true}, {'hrsh7th/vim-vsnip-integ', opt = true}}
  }

  -- Plugins can also depend on rocks from luarocks.org:
  use {
    'my/supercoolplugin',
    rocks = {'lpeg', {'lua-cjson', version = '2.1.0'}}
  }

  -- You can specify rocks in isolation
  use_rocks 'penlight'
  use_rocks {'lua-resty-http', 'lpeg'}

  -- Local plugins can be included
  use '~/projects/personal/hover.nvim'

  -- Plugins can have post-install/update hooks
  use {'iamcco/markdown-preview.nvim', run = 'cd app && yarn install', cmd = 'MarkdownPreview'}

  -- Post-install/update hook with neovim command
  use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }

  -- Post-install/update hook with call of vimscript function with argument
  use { 'glacambre/firenvim', run = function() vim.fn['firenvim#install'](0) end }

  -- Use specific branch, dependency and run lua file after load
  use {
    'glepnir/galaxyline.nvim', branch = 'main', config = function() require'statusline' end,
    requires = {'kyazdani42/nvim-web-devicons'}
  }

  -- Use dependency and run lua function after load
  use {
    'lewis6991/gitsigns.nvim', requires = { 'nvim-lua/plenary.nvim' },
    config = function() require('gitsigns').setup() end
  }

  -- You can specify multiple plugins in a single call
  use {'tjdevries/colorbuddy.vim', {'nvim-treesitter/nvim-treesitter', opt = true}}

  -- You can alias plugin names
  use {'dracula/vim', as = 'dracula'}
end)

Note that if you get linter complaints about use being an undefined global, these errors are spurious - packer injects use into the scope of the function passed to startup. If these errors bother you, the easiest fix is to simply specify use as an argument to the function you pass to startup, e.g.

packer.startup(function(use)
...your config...
end)

packer provides the following commands after you've run and configured packer with require('packer').startup(...):

-- You must run this or `PackerSync` whenever you make changes to your plugin configuration
-- Regenerate compiled loader file
:PackerCompile

-- Remove any disabled or unused plugins
:PackerClean

-- Clean, then install missing plugins
:PackerInstall

-- Clean, then update and install plugins
-- supports the `--preview` flag as an optional first argument to preview updates
:PackerUpdate

-- Perform `PackerUpdate` and then `PackerCompile`
-- supports the `--preview` flag as an optional first argument to preview updates
:PackerSync

-- Show list of installed plugins
:PackerStatus

-- Loads opt plugin immediately
:PackerLoad completion-nvim ale

You can configure Neovim to automatically run :PackerCompile whenever plugins.lua is updated with an autocommand:

augroup packer_user_config
  autocmd!
  autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end

This autocommand can be placed in your init.vim, or any other startup file as per your setup. Placing this in plugins.lua could look like this:

vim.cmd([[
  augroup packer_user_config
    autocmd!
    autocmd BufWritePost plugins.lua source <afile> | PackerCompile
  augroup end
]])

Bootstrapping

If you want to automatically install and set up packer.nvim on any machine you clone your configuration to, add the following snippet (which is due to @Iron-E and @khuedoan) somewhere in your config before your first usage of packer:

local ensure_packer = function()
  local fn = vim.fn
  local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
  if fn.empty(fn.glob(install_path)) > 0 then
    fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
    vim.cmd [[packadd packer.nvim]]
    return true
  end
  return false
end

local packer_bootstrap = ensure_packer()

return require('packer').startup(function(use)
  use 'wbthomason/packer.nvim'
  -- My plugins here
  -- use 'foo1/bar1.nvim'
  -- use 'foo2/bar2.nvim'

  -- Automatically set up your configuration after cloning packer.nvim
  -- Put this at the end after all plugins
  if packer_bootstrap then
    require('packer').sync()
  end
end)

You can also use the following command (with packer bootstrapped) to have packer setup your configuration (or simply run updates) and close once all operations are completed:

$ nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'

Usage

The above snippets give some examples of packer features and use. Examples include:

The following is a more in-depth explanation of packer's features and use.

The startup function

packer provides packer.startup(spec), which is used in the above examples.

startup is a convenience function for simple setup and can be invoked as follows:

  • spec can be a function: packer.startup(function() use 'tjdevries/colorbuddy.vim' end)
  • spec can be a table with a function as its first element and config overrides as another element: packer.startup({function() use 'tjdevries/colorbuddy.vim' end, config = { ... }})
  • spec can be a table with a table of plugin specifications as its first element, config overrides as another element, and optional rock specifications as another element: packer.startup({{'tjdevries/colorbuddy.vim'}, config = { ... }, rocks = { ... }})

Custom Initialization

You are not required to use packer.startup if you prefer a more manual setup with finer control over configuration and loading.

To take this approach, load packer like any other Lua module. You must call packer.init() before performing any operations; it is recommended to call packer.reset() if you may be re-running your specification code (e.g. by sourcing your plugin specification file with luafile).

You may pass a table of configuration values to packer.init() to customize its operation. The default configuration values (and structure of the configuration table) are:

local packer = require('packer')
packer.util = require('packer.util')

packer.init({
  ensure_dependencies = true, -- Should packer install plugin dependencies?
  snapshot = nil, -- Name of the snapshot you would like to load at startup
  snapshot_path = packer.util.join_paths(vim.fn.stdpath('cache'), 'packer.nvim'), -- Default save directory for snapshots
  package_root  = packer.util.join_paths(vim.fn.stdpath('data'), 'site', 'pack'),
  compile_path  = packer.util.join_paths(vim.fn.stdpath('config'), 'plugin', 'packer_compiled.lua'),
  plugin_package = 'packer', -- The default package for plugins
  max_jobs = nil, -- Limit the number of simultaneous jobs. nil means no limit
  auto_clean = true, -- During sync(), remove unused plugins
  compile_on_sync = true, -- During sync(), run packer.compile()
  disable_commands = false, -- Disable creating commands
  opt_default = false, -- Default to using opt (as opposed to start) plugins
  transitive_opt = true, -- Make dependencies of opt plugins also opt by default
  transitive_disable = true, -- Automatically disable dependencies of disabled plugins
  auto_reload_compiled = true, -- Automatically reload the compiled file after creating it.
  preview_updates = false, -- If true, always preview updates before choosing which plugins to update, same as `PackerUpdate --preview`.
  git = {
    cmd = 'git', -- The base command for git operations
    subcommands = { -- Format strings for git subcommands
      update         = 'pull --ff-only --progress --rebase=false --force',
      install        = 'clone --depth %i --no-single-branch --progress',
      fetch          = 'fetch --depth 999999 --progress --force',
      checkout       = 'checkout %s --',
      update_branch  = 'merge --ff-only @{u}',
      current_branch = 'branch --show-current',
      diff           = 'log --color=never --pretty=format:FMT --no-show-signature HEAD@{1}...HEAD',
      diff_fmt       = '%%h %%s (%%cr)',
      get_rev        = 'rev-parse --short HEAD',
      get_msg        = 'log --color=never --pretty=format:FMT --no-show-signature HEAD -n 1',
      submodules     = 'submodule update --init --recursive --progress'
    },
    depth = 1, -- Git clone depth
    clone_timeout = 60, -- Timeout, in seconds, for git clones
    default_url_format = 'https://github.com/%s' -- Lua format string used for "aaa/bbb" style plugins
  },
  display = {
    non_interactive = false, -- If true, disable display windows for all operations
    compact = false, -- If true, fold updates results by default
    open_fn  = nil, -- An optional function to open a window for packer's display
    open_cmd = '65vnew \\[packer\\]', -- An optional command to open a window for packer's display
    working_sym = '', -- The symbol for a plugin being installed/updated
    error_sym = '', -- The symbol for a plugin with an error in installation/updating
    done_sym = '', -- The symbol for a plugin which has completed installation/updating
    removed_sym = '-', -- The symbol for an unused plugin which was removed
    moved_sym = '', -- The symbol for a plugin which was moved (e.g. from opt to start)
    header_sym = '', -- The symbol for the header line in packer's display
    show_all_info = true, -- Should packer show all update details automatically?
    prompt_border = 'double', -- Border style of prompt popups.
    keybindings = { -- Keybindings for the display window
      quit = 'q',
      toggle_update = 'u', -- only in preview
      continue = 'c', -- only in preview
      toggle_info = '<CR>',
      diff = 'd',
      prompt_revert = 'r',
    }
  },
  luarocks = {
    python_cmd = 'python' -- Set the python command to use for running hererocks
  },
  log = { level = 'warn' }, -- The default print log level. One of: "trace", "debug", "info", "warn", "error", "fatal".
  profile = {
    enable = false,
    threshold = 1, -- integer in milliseconds, plugins which load faster than this won't be shown in profile output
  },
  autoremove = false, -- Remove disabled or unused plugins without prompting the user
})

Specifying plugins

packer is based around declarative specification of plugins. You can declare a plugin using the function packer.use, which I highly recommend locally binding to use for conciseness.

use takes either a string or a table. If a string is provided, it is treated as a plugin location for a non-optional plugin with no additional configuration. Plugin locations may be specified as

  1. Absolute paths to a local plugin
  2. Full URLs (treated as plugins managed with git)
  3. username/repo paths (treated as Github git plugins)

A table given to use can take two forms:

  1. A list of plugin specifications (strings or tables)
  2. A table specifying a single plugin. It must have a plugin location string as its first element, and may additionally have a number of optional keyword elements, shown below:
use {
  'myusername/example',        -- The plugin location string
  -- The following keys are all optional
  disable = boolean,           -- Mark a plugin as inactive
  as = string,                 -- Specifies an alias under which to install the plugin
  installer = function,        -- Specifies custom installer. See "custom installers" below.
  updater = function,          -- Specifies custom updater. See "custom installers" below.
  after = string or list,      -- Specifies plugins to load before this plugin. See "sequencing" below
  rtp = string,                -- Specifies a subdirectory of the plugin to add to runtimepath.
  opt = boolean,               -- Manually marks a plugin as optional.
  bufread = boolean,           -- Manually specifying if a plugin needs BufRead after being loaded
  branch = string,             -- Specifies a git branch to use
  tag = string,                -- Specifies a git tag to use. Supports '*' for "latest tag"
  commit = string,             -- Specifies a git commit to use
  lock = boolean,              -- Skip updating this plugin in updates/syncs. Still cleans.
  run = string, function, or table, -- Post-update/install hook. See "update/install hooks".
  requires = string or list,   -- Specifies plugin dependencies. See "dependencies".
  rocks = string or list,      -- Specifies Luarocks dependencies for the plugin
  config = string or function, -- Specifies code to run after this plugin is loaded.
  -- The setup key implies opt = true
  setup = string or function,  -- Specifies code to run before this plugin is loaded. The code is ran even if
                               -- the plugin is waiting for other conditions (ft, cond...) to be met.
  -- The following keys all imply lazy-loading and imply opt = true
  cmd = string or list,        -- Specifies commands which load this plugin. Can be an autocmd pattern.
  ft = string or list,         -- Specifies filetypes which load this plugin.
  keys = string or list,       -- Specifies maps which load this plugin. See "Keybindings".
  event = string or list,      -- Specifies autocommand events which load this plugin.
  fn = string or list          -- Specifies functions which load this plugin.
  cond = string, function, or list of strings/functions,   -- Specifies a conditional test to load this plugin
  module = string or list      -- Specifies Lua module names for require. When requiring a string which starts
                               -- with one of these module names, the plugin will be loaded.
  module_pattern = string/list -- Specifies Lua pattern of Lua module names for require. When
                               -- requiring a string which matches one of these patterns, the plugin will be loaded.
}

For the cmd option, the command may be a full command, or an autocommand pattern. If the command contains any non-alphanumeric characters, it is assumed to be a pattern, and instead of creating a stub command, it creates a CmdUndefined autocmd to load the plugin when a command that matches the pattern is invoked.

Checking plugin statuses

You can check whether or not a particular plugin is installed with packer as well as if that plugin is loaded. To do this you can check for the plugin's name in the packer_plugins global table. Plugins in this table are saved using only the last section of their names e.g. tpope/vim-fugitive if installed will be under the key vim-fugitive.

if packer_plugins["vim-fugitive"] and packer_plugins["vim-fugitive"].loaded then
print("Vim fugitive is loaded")
-- other custom logic
end

NOTE: this table is only available after packer_compiled.vim is loaded so cannot be used till after plugins have been loaded.

Luarocks support

You may specify that a plugin requires one or more Luarocks packages using the rocks key. This key takes either a string specifying the name of a package (e.g. rocks=lpeg), or a list specifying one or more packages. Entries in the list may either be strings, a list of strings or a table --- the latter case is used to specify arguments such as the particular version of a package. all supported luarocks keys are allowed except: tree and local. Environment variables for the luarocks command can also be specified using the env key which takes a table as the value as shown below.

rocks = {'lpeg', {'lua-cjson', version = '2.1.0'}}
use_rocks {'lua-cjson', 'lua-resty-http'}
use_rocks {'luaformatter', server = 'https://luarocks.org/dev'}
use_rocks {'openssl' env = {OPENSSL_DIR = "/path/to/dir"}}

Currently, packer only supports equality constraints on package versions.

packer also provides the function packer.luarocks.install_commands(), which creates the PackerRocks <cmd> <packages...> command. <cmd> must be one of "install" or "remove"; <packages...> is one or more package names (currently, version restrictions are not supported with this command). Running PackerRocks will install or remove the given packages. You can use this command even if you don't use packer to manage your plugins. However, please note that (1) packages installed through PackerRocks will be removed by calls to packer.luarocks.clean() (unless they are also part of a packer plugin specification), and (2) you will need to manually invoke packer.luarocks.setup_paths (or otherwise modify your package.path) to ensure that Neovim can find the installed packages.

Finally, packer provides the function packer.use_rocks, which takes a string or table specifying one or more Luarocks packages as in the rocks key. You can use this to ensure that packer downloads and manages some rocks which you want to use, but which are not associated with any particular plugin.

Custom installers

You may specify a custom installer & updater for a plugin using the installer and updater keys. Note that either both or none of these keys are required. These keys should be functions which take as an argument a display object (from lua/packer/display.lua) and return an async function (per lua/packer/async.lua) which (respectively) installs/updates the given plugin.

Providing the installer/updater keys overrides plugin type detection, but you still need to provide a location string for the name of the plugin.

Update/install hooks

You may specify operations to be run after successful installs/updates of a plugin with the run key. This key may either be a Lua function, which will be called with the plugin table for this plugin (containing the information passed to use as well as output from the installation/update commands, the installation path of the plugin, etc.), a string, or a table of functions and strings.

If an element of run is a string, then either:

  1. If the first character of run is ":", it is treated as a Neovim command and executed.
  2. Otherwise, run is treated as a shell command and run in the installation directory of the plugin via $SHELL -c '<run>'.

Dependencies

Plugins may specify dependencies via the requires key. This key can be a string or a list (table).

If requires is a string, it is treated as specifying a single plugin. If a plugin with the name given in requires is already known in the managed set, nothing happens. Otherwise, the string is treated as a plugin location string and the corresponding plugin is added to the managed set.

If requires is a list, it is treated as a list of plugin specifications following the format given above.

If ensure_dependencies is true, the plugins specified in requires will be installed.

Plugins specified in requires are removed when no active plugins require them.

Sequencing

You may specify a loading order for plugins using the after key. This key can be a string or a list (table).

If after is a string, it must be the name of another plugin managed by packer (e.g. the final segment of a plugin's path - for a Github plugin FooBar/Baz, the name would be just Baz). If after is a table, it must be a list of plugin names. If a plugin has an alias (i.e. uses the as key), this alias is its name.

The set of plugins specified in a plugin's after key must all be loaded before the plugin using after will be loaded. For example, in the specification

  use {'FooBar/Baz', ft = 'bax'}
  use {'Something/Else', after = 'Baz'}

the plugin Else will only be loaded after the plugin Baz, which itself is only loaded for files with bax filetype.

Keybindings

Plugins may be lazy-loaded on the use of keybindings/maps. Individual keybindings are specified either as a string (in which case they are treated as normal mode maps) or a table in the format {mode, map}.

Performing plugin management operations

packer exposes the following functions for common plugin management operations. In all of the below, plugins is an optional table of plugin names; if not provided, the default is "all managed plugins":

  • packer.install(plugins): Install the specified plugins if they are not already installed
  • packer.update(plugins): Update the specified plugins, installing any that are missing
  • packer.update(opts, plugins): First argument can be a table specifying options, such as {preview_updates = true} to preview potential changes before updating (same as PackerUpdate --preview).
  • packer.clean(): Remove any disabled or no longer managed plugins
  • packer.sync(plugins): Perform a clean followed by an update.
  • packer.sync(opts, plugins): Can take same optional options as update.
  • packer.compile(path): Compile lazy-loader code and save to path.
  • packer.snapshot(snapshot_name, ...): Creates a snapshot file that will live under config.snapshot_path/<snapshot_name>. If snapshot_name is an absolute path, then that will be the location where the snapshot will be taken. Optionally, a list of plugins name can be provided to selectively choose the plugins to snapshot.
  • packer.rollback(snapshot_name, ...): Rollback plugins status a snapshot file that will live under config.snapshot_path/<snapshot_name>. If snapshot_name is an absolute path, then that will be the location where the snapshot will be taken. Optionally, a list of plugins name can be provided to selectively choose which plugins to revert.
  • packer.delete(snapshot_name): Deletes a snapshot file under config.snapshot_path/<snapshot_name>. If snapshot_name is an absolute path, then that will be the location where the snapshot will be deleted.

Extending packer

You can add custom key handlers to packer by calling packer.set_handler(name, func) where name is the key you wish to handle and func is a function with the signature func(plugins, plugin, value) where plugins is the global table of managed plugins, plugin is the table for a specific plugin, and value is the value associated with key name in plugin.

Compiling Lazy-Loaders

To optimize startup time, packer.nvim compiles code to perform the lazy-loading operations you specify. This means that you do not need to load packer.nvim unless you want to perform some plugin management operations.

To generate the compiled code, call packer.compile(path), where path is some file path on your runtimepath, with a .vim extension. This will generate a blend of Lua and Vimscript to load and configure all your lazy-loaded plugins (e.g. generating commands, autocommands, etc.) and save it to path. Then, when you start vim, the file at path is loaded (because path must be on your runtimepath), and lazy-loading works.

If path is not provided to packer.compile, the output file will default to the value of config.compile_path.

The option compile_on_sync, which defaults to true, will run packer.compile() during packer.sync(), if set to true. Note that otherwise, you must run packer.compile yourself to generate the lazy-loader file!

NOTE: If you use a function value for config or setup keys in any plugin specifications, it must not have any upvalues (i.e. captures). We currently use Lua's string.dump to compile config/setup functions to bytecode, which has this limitation. Additionally, if functions are given for these keys, the functions will be passed the plugin name and information table as arguments.

User autocommands

packer runs most of its operations asyncronously. If you would like to implement automations that require knowing when the operations are complete, you can use the following User autocmds (see :help User for more info on how to use):

  • PackerComplete: Fires after install, update, clean, and sync asynchronous operations finish.
  • PackerCompileDone: Fires after compiling (see the section on compilation)

Using a floating window

You can configure Packer to use a floating window for command outputs by passing a utility function to packer's config:

packer.startup({function()
  -- Your plugins here
end,
config = {
  display = {
    open_fn = require('packer.util').float,
  }
}})

By default, this floating window will show doubled borders. If you want to customize the window appearance, you can pass a configuration to float, which is the same configuration that would be passed to nvim_open_win:

packer.startup({function()
  -- Your plugins here
end,
config = {
  display = {
    open_fn = function()
      return require('packer.util').float({ border = 'single' })
    end
  }
}})

Profiling

Packer has built in functionality that can allow you to profile the time taken loading your plugins. In order to use this functionality you must either enable profiling in your config, or pass in an argument when running packer compile.

Setup via config

config = {
  profile = {
    enable = true,
    threshold = 1 -- the amount in ms that a plugin's load time must be over for it to be included in the profile
  }
}

Using the packer compile command

:PackerCompile profile=true
" or
:PackerCompile profile=false

Profiling usage

This will rebuild your packer_compiled.vim with profiling code included. In order to visualise the output of the profile restart your neovim and run PackerProfile. This will open a window with the output of your profiling.

Debugging

packer.nvim logs to stdpath(cache)/packer.nvim.log. Looking at this file is usually a good start if something isn't working as expected.

Compatibility and known issues

  • 2021-07-31: If you're on macOS, note that building Neovim with the version of luv from homebrew will cause any packer command to crash. More about this issue at neovim/neovim#15054.
  • 2021-07-28: packer will now highlight commits/plugin names with potentially breaking changes (determined by looking for breaking change or breaking_change, case insensitive, in the update commit bodies and headers) as WarningMsg in the status window.
  • 2021-06-06: Your Neovim must include neovim/neovim#14659; packer uses the noautocmd key.
  • 2021-04-19: packer now provides built-in profiling for your config via the packer_compiled file. Take a look at the docs for more information!
  • 2021-02-18: Having trouble with Luarocks on macOS? See this issue.
  • 2021-01-19: Basic Luarocks support has landed! Use the rocks key with a string or table to specify packages to install.
  • 2020-12-10: The disable_commands configuration flag now affects non-startup use as well. This means that, by default, packer will create commands for basic operations for you.
  • 2020-11-13: There is now a default implementation for a floating window open_fn in packer.util.
  • 2020-09-04: Due to changes to the Neovim extmark api (see: https://github.com/neovim/neovim/commit/3853276d9cacc99a2698117e904475dbf7033383), users will need to update to a version of Neovim after the aforementioned PR was merged. There are currently shims around the changed functions which should maintain support for earlier versions of Neovim, but these are intended to be temporary and will be removed by 2020-10-04. Therefore Packer will not work with Neovim v0.4.4, which was released before the extmark change.

Contributors

Many thanks to those who have contributed to the project! PRs and issues are always welcome. This list is infrequently updated; please feel free to bug me if you're not listed here and you would like to be.

packer.nvim's People

Contributors

aberrantian avatar acksld avatar akinsho avatar amlmn avatar andreadev-it avatar axieax avatar brphilly avatar craigmac avatar deathlyfrantic avatar doctoromer avatar dsully avatar dundargoc avatar edeneast avatar elianiva avatar gbrlsnchs avatar github-actions[bot] avatar iron-e avatar jdelkins avatar kevinhwang91 avatar koshell avatar lewis6991 avatar n3wborn avatar nanotee avatar numtostr avatar runiq avatar shadmansaleh avatar tjdevries avatar wbthomason avatar weilbith avatar younger-1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer.nvim's Issues

Neovim versions <0.5.0 are incompatible: missing extmarks API

I followed the quick start guide on the README and when I ran PackerInstall I got the the following error.

E5105: Error while calling lua chunk: ...are/nvim/site/pack/packer/opt/packer.nvim/lua/packer.lua:75: atte
mpt to index field 'fn' (a nil value)

"if" in requires

Currently I have

  use {
    'nvim-lua/completion-nvim',
    opt = true,
    requires = {{'hrsh7th/vim-vsnip', opt = true}, {'hrsh7th/vim-vsnip-integ', opt = true}, {'ncm2/float-preview.nvim', opt = true}, {'aca/completion-tabnine', opt = true}}
  }

I want to require ncm2/float-preview.nvim only if a particular global variable g:xyz is not set. How would I do that?

`require` format uses slashes

I think it's better if we use . notation instead of / for requires. We should probably standardize on that.

I think require('x.y') makes a different module than require('x/y') btw

Disabled plugins get picked up by PackerClean

I sometimes want to disable plugins along with their associated configuration while still keeping them installed and up to date. I assumed that was the goal of the disable option but the :PackerClean command asks me if I want to remove plugins that are disabled. Am I misunderstanding the purpose of disable?

Refactor plugin full vs short names

As noted in #45, there may be a bug on Windows in the path separator used for full names. Additionally, the full/short name system is annoyingly ad hoc and has caused bugs in the past. It should be refactored to more cleanly separate and identify the purposes of the two "types" of plugin name.

Howto: Add package from a number of files

Hi there, I currently use minpac and I’m eager to test out and use packer.nvim.

I have the following conf structure under ~/.config/nvim :

- Modules
   - X
      - packages.lua   
   - Y
      - packages.lua   
   - Z
   - ...

With minpac I have add-calls in packages.lua, which gets loaded whenever I want to update or install packages and call util.update_packages().

Example content of packages.lua
vim.cmd"call minpac#add('vim-jp/syntax-vim-ex"

I wonder how to achieve the similar result with packer.nvim?

I’d deeply appreciate a code snippet to get me started. 🙏 Thanks a lot, hope it okay it to post how to here.

packer_compile.vim does not degrade gracefully when sourced with vim

I use the same configuration for both nvim and vim. I use nvim primarily but sometimes I have to use vim (when making a git commit when I am on mintty/git-bash). In my configuration I feature check and gracefully degrade my configuration. That means that I will not have all my plugins and nice to haves but my core vim settings will be the same. This is fine for the small instances where I have to use vim.

Currently the packer_compiled.vim file is added to the plugin folder in your runtimepath. When running vim I get these errors

Error detected while processing /c/Users/James/.local/share/nvim/plugin/packer_compiled.vim:
line    3:
E319: Sorry, the command is not available in this version: lua << END
line    4:
E492: Not an editor command: local plugins = {
line    5:
E492: Not an editor command:   ["packer.nvim"] = {
...

Having a feature guard for nvim before the lua section would solve this issue.

Make lazy-loader compilation more automatic

As mentioned in #4, it's inconvenient and confusing to have to call packer.compile() manually. This process should be made more automatic.

One option is to add a config key containing a path for the compiler output. If this key exists, compile() gets run automatically after all operations.

Additionally (as @tjdevries suggested on Gitter), perhaps the lazy-loader could check if the last modified time of the plugin specification file is after the last modified time of the compiled lazy-loaders, and update itself if so.

Custom name

How do I do the vim-plug equivalent of Plug 'dracula/vim', { 'as': 'dracula' } (ie install it in a folder named dracula or else it would be installed in a folder named vim because the repository is https://github.com/dracula/vim)

Can't seem to figure out setup

I get this on startup (imgur wasn't working)
https://drive.google.com/file/d/1RdXTqghguJYjODTaCUs_tqr5zZx2R1d6/view?usp=sharing
It is looking for stuff in the wrong places, so I'm obviously doing something wrong.
What I did:

  1. git clone https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/opt/packer.nvim

  2. My init.vim:

lua require('packer').startup()
lua require('plugins')
"aniseed.dotfiles, colorizer and bufferline are from plugins
lua require('aniseed.dotfiles')
lua require'colorizer'.setup()
lua require'bufferline'.setup()
"treesitter_setup.lua is a file in .config/nvim/lua/
lua require'treesitter_setup'

lua require'nvim_lsp'.vimls.setup {on_attach=require'diagnostic'.on_attach()}
lua require'nvim_lsp'.bashls.setup{on_attach=require'diagnostic'.on_attach()}
lua require'nvim_lsp'.jdtls.setup{on_attach=require'diagnostic'.on_attach()}
  1. .config/nvim/lua/plugins.lua:
-- This file can be loaded by calling `lua require('plugins')` from your init.vim

-- Only required if you have packer in your `opt` pack
vim.cmd [[packadd packer.nvim]]
-- Temporary until https://github.com/neovim/neovim/pull/12632 is merged
vim._update_package_paths()


return require('packer').startup(function()
  use {'wbthomason/packer.nvim'}
  use 'Akin909/nvim-bufferline.lua'
  use {'bakpakin/fennel.vim', ft = {'fnl'}}
  use {'camspiers/lens.vim', requires = {{'camspiers/animate.vim'}}}
  use 'dense-analysis/ale'
  use {'dracula/vim'}
  use 'editorconfig/editorconfig-vim'
  use {'guns/vim-sexp', ft = {'clj', 'fnl'}, requires = 'tpope/vim-sexp-mappings-for-regular-people'}
  use 'hardcoreplayers/dashboard-nvim'
  -- Plugins can have post-install/update hooks
  use {'iamcco/markdown-preview.nvim', run = 'cd app && yarn install', cmd = 'MarkdownPreview', ft = {'md', 'mkdn', 'vim-plug'}}
  use 'jeffkreeftmeijer/vim-numbertoggle'
  use 'jiangmiao/auto-pairs'
  use 'justinmk/vim-gtfo'
  use 'justinmk/vim-sneak'
  use {'kassio/neoterm',
    cmd = {'TNew'}
  }
  use {'kyazdani42/nvim-tree.lua', requires = {'kyazdani42/nvim-web-devicons'}}
  use {'liuchengxu/vim-clap', config = 'vim.cmd[[Clap install-binary!]]'}
  use 'liuchengxu/vista.vim'
  use 'mattn/vim-sonictemplate'
  use 'mhinz/vim-signify'
  use {
    'nvim-lua/completion-nvim',
    opt = true,
    requires = {{'hrsh7th/vim-vsnip'}, {'hrsh7th/vim-vsnip-integ'}, {'ncm2/float-preview.nvim'}, {'aca/completion-tabnine'}}
  }
  use {'neovim/nvim-lsp', requires = {'nvim-lua/lsp-status.nvim', 'nvim-lua/diagnostic-nvim'}}
  use 'norcalli/nvim-colorizer.lua'
  use 'nvim-treesitter/nvim-treesitter'
  use 'Olical/aniseed'
  use {'Olical/conjure', ft = {'fnl', 'clj'}}
  use 'pbrisbin/vim-mkdir'
  use 'psliwka/vim-smoothie'
  use 'tpope/vim-fugitive'
  use 'tpope/vim-surround'
  use 'tyru/caw.vim'
  use {'reedes/vim-pencil', ft = {'txt', 'md', 'mkdn', 'rst'}}
  use 'rhysd/git-messenger.vim'
--TODO  use 'skywind3000/vim-quickui'
  use {'vigoux/LanguageTool.nvim',
--TODO    ft = {}
}
  use 'vim-airline/vim-airline'
  use{'Yggdroot/indentLine', requires = 'lukas-reineke/indent-blankline.nvim'}
  use 'ryanoasis/vim-devicons'
end)

Packer hangs when setting a maximum number of simultaneous jobs

I am using the init function to limit the number of jobs, but it doesn't seem to work. Here's an approximation of what my config looks like:

vim.cmd 'packadd! packer.nvim'

local packer = require('packer')

packer.init {
    max_jobs = 5,
}

packer.startup(function(use)
    use 'user/plugin1'
    use 'user/plugin2'
    use 'user/plugin3'
    use 'user/plugin4'
    use 'user/plugin5'
    use 'user/plugin6'
    use 'user/plugin7'
    use 'user/plugin8'
    use 'user/plugin9'
    use 'user/plugin10'
end)

When I run :PackerUpdate, Packer outputs something like this:

            packer.nvim - updating 5 / 10 plugins            
 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 
 ✓ user/plugin1: already up to date
 ✓ user/plugin2: already up to date
 ✓ user/plugin3: already up to date
 ✓ user/plugin4: already up to date
 ✓ user/plugin5: already up to date

It never actually reaches the end screen and waits indefinitely. I can still move my cursor and quit Neovim just fine.

I may be doing something wrong, but I don't know what

Configuration table is not handled correctly by init

(Sorry for the vague title.)

It seems that the config table that is not correctly merged with the default values. I am following the example setup in the readme, except that I want to pass a table to packer.init(). However, this prevents the package handling functionality (install, update, etc.) from working; nothing happens. Specifically, if I pass

{
  display = {
    open_cmd = 'new [packer]',
    working_sym = '', -- The symbol for a plugin being installed/updated
    error_sym = '', -- The symbol for a plugin with an error in installation/updating
    done_sym = '', -- The symbol for a plugin which has completed installation/updating
    removed_sym = '-', -- The symbol for an unused plugin which was removed
    moved_sym = '', -- The symbol for a plugin which was moved (e.g. from opt to start)
    header_sym = '', -- The symbol for the header line in packer's display
  }
}

the new buffer is opened, but nothing happens. This is even the case if I paste the full table with default values from the readme. If I omit one of the symbols from the table, packer complains about

E5108: Error executing lua ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:299: attempt to concate
nate local 'working_sym' (a nil value)

Command to list installed plugins

It would be useful (sometimes) to have a function that lists the plugins managed by packer together with some rudimentary information -- mainly whether it's a start or an opt plugin, and maybe the source (commit hash, branch, local dir...). As a bonus, it could show the full config dictionary when selected (just like the update command shows the git log after updating).

I saw there's already a packer/display function, but that is not exposed?

Install freezes if not a valid git repository

If you try and install an invalid repo using packer, the entire Neovim freezes and you can't do anything about it.

I was able to reproduce with use 'asdfasdfasdf/asdfasdfasdf'

(This is on WSL, I can check somewhere else later as well)

Allow setting opt by default

I've been using vim packages for some time and have almost all plugins installed as opt = true. I do packadd! in init.vim or packadd elsewhere as needed. It makes it easy to disable plugins in my experience.

Is there a way to do this with packer? There may be some fancy lua trick that can be used that I'm not aware of. If not, can this be added as a configuration option? (vim-packager has this)

Document results window keybindings and make display function

There are three keybindings made in the results window to quit (q), show more info (), and revert an update (r). These should be (1) documented and (2) there should be something printed in the results window notifying users that the keybindings exist.

vim.fn.executable is not reliable

I don't really know why this it the case, but if you don't have set shell=powershell on windows, then vim thinks that mklink is not executable, even though it is.

I guess mklink is not an executable in cmd, but in powershell it is? I am really confused.

I'll try to find an alternative.

To be honest, I think you can assume that mklink exists on Windows right?

Update:

I now tested again with set shell=powershell and it still doesn't work. I can execute mklink using :!mklink, so I think something else is the problem.

Why `signcolumn=yes:2`?

Just wondering: What is the point of signcolumn=yes:2 in the packer.nvim window? I haven't ever seen any output in there…

Can't install plugins

init.vim

packadd packer.nvim 

execute 'luafile ' . stdpath('config') . '/lua/plugins.lua'

command! PackerInstall lua require('plugins').install()
command! PackerUpdate lua require('plugins').update()
command! PackerSync lua require('plugins').sync()
command! PackerClean lua require('plugins').clean()
command! PackerCompile lua require('plugins').compile(

lua/plugins.lua

return require('packer').startup(function()
    use {'wbthomason/packer.nvim', opt = true}
    use 'morhetz/gruvbox'
end)

When I run :PackerCompile followed by :PackerInstall it fails to install both plugins.

I am using NVIM v0.5.0-659-g7b1b271f4 on Windows 10.

Can I somehow provide you with some logs?

Add time-deferred loaders

Mentioned in #4 - make it possible to specify a plugin to be loaded after some delay (not based on an autocommand).

PackerCompile sometimes produces invalid code

First of all, thank you for making such a nice plugin. I've been switching my config over to Packer and it is a joy to use. I particularly like the code generation feature, it allows me to simplify my configuration and smoothes over some of the rough edges of native packages.

Unfortunately I seem to have hit a few edge cases while making the transition. I apologize in advance for being "that annoying user" :)

Under certain circumstances, Packer will generate invalid code. I wrote a minimal packages.lua that reproduces the issue:

vim.cmd 'packadd! packer.nvim'

require'packer'.startup(function(use)
    use {
        'glacambre/firenvim',
        cond = 'vim.g.started_by_firenvim',
        config = function()
            vim.o.laststatus = 0
            vim.bo.filetype = 'markdown'
        end,
    }
end)

And here's the code being generated by packer:

-- Conditional loads
if
    vim.g.started_by_firenvim
    then
      vim.cmd("packadd firenvim")
	
	-- Config for: firenvim
	^[LJ^B^BQ^@^@^B^@^F^@  6^@^@^@9^@^A^@)^A^@^@=^A^B^@6^@^@^@9^@^C^@'^A^E^@=^A^D^@K^@^A^@^Mmarkdown^Mfiletype^Gbo^Olaststatus^Fo^Hvim^@

    end

I'm assuming the combination of using cond and passing a function to config is what causes the problem. Passing a string to it instead solves the issue.

Error detected while processing function <SNR>27_load

I get this error when opening a group of files

Error detected while processing function <SNR>27_load
line      1:
E5108: Error executing lua [string "..."]:0 attempt to index upvalue ' ' (a nil value)
Press ENTER or type command to continue

NOTE: the ... upvalue ' ' is actually two single quotes without a space. I added the space for legibility

I have troubleshooted this to this portion of my packer compiled plugin

augroup packer_load_aucmds
  au!
  " Filetype lazy-loads
  au FileType sh ++once call s:load(['nvim-treesitter', 'vim-sh', 'completion-tags', 'completion-treesitter'], { "ft": "sh" })
augroup END

NOTE: This happens on other files with similiar autocmds

I'm not sure where it's getting tripped up.

Error on :PackerUpdate

After b11f288 I get

Error executing vim.schedule lua callback: .../site/pack/packer/opt/packer.nvim/lua/packer/display.lua:90: Expected lua number                                                                                                              
Error executing vim.schedule lua callback: .../site/pack/packer/opt/packer.nvim/lua/packer/display.lua:129: Expected lua number
Error executing vim.schedule lua callback: .../site/pack/packer/opt/packer.nvim/lua/packer/display.lua:107: Expected lua number

on :PackerUpdate.

Checking out to the previous commit fixes it, so I don't think I messed something up

Profiling and performance tuning

Most of the computational cost of packer goes to running git, etc. However, it would be worthwhile to profile major components like manage, compile, the generated lazy-loader code (in some representative cases), etc. to see if there's anywhere we can improve performance.

It would also be worthwhile to see if the loading time of packer can be decreased, i.e. by making modules lighter to require or only conditionally requiring modules. Probably worth seeing how much time goes to requires to start with, though.

question with startup time

code in here https://github.com/glepnir/nvim/blob/packer/lua/loadpack.lua just three plugins. check startuptime..it takes too long time.

times in msec
 clock   self+sourced   self:  sourced script
 clock   elapsed:              other lines

000.013  000.013: --- NVIM STARTING ---
001.175  001.162: locale set
002.016  000.841: inits 1
002.045  000.029: window checked
002.049  000.004: parsing arguments
002.296  000.246: expanding arguments
002.374  000.078: inits 2
002.972  000.598: init highlight
002.973  000.001: waiting for UI
007.314  004.341: done waiting for UI
007.397  000.083: initialized screen early for UI
182.268  014.178  014.178: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/filetype.vim
182.588  000.076  000.076: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/ftplugin.vim
182.819  000.055  000.055: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/indent.vim
183.714  000.403  000.403: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/syntax/syncolor.vim
183.873  000.737  000.334: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/syntax/synload.vim
183.911  000.935  000.199: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/syntax/syntax.vim
186.185  000.240  000.240: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/syntax/syncolor.vim
187.663  000.310  000.310: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/syntax/syncolor.vim
188.521  000.220  000.220: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/syntax/syncolor.vim
189.009  000.220  000.220: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/syntax/syncolor.vim
192.754  006.112  005.362: sourcing /Users/stephen/.config/nvim/colors/oceanic_material.vim
192.841  184.905  163.308: sourcing /Users/stephen/.config/nvim/init.vim
192.857  000.556: sourcing vimrc file(s)
195.339  000.089  000.089: sourcing /Users/stephen/.config/nvim/plugin/bufkill.vim
195.597  000.200  000.200: sourcing /Users/stephen/.config/nvim/plugin/difftools.vim
195.877  000.155  000.155: sourcing /Users/stephen/.config/nvim/plugin/hlsearch.vim
196.114  000.178  000.178: sourcing /Users/stephen/.config/nvim/plugin/whitespace.vim
197.230  000.028  000.028: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/gzip.vim
197.324  000.022  000.022: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/health.vim
197.506  000.115  000.115: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/man.vim
198.984  000.074  000.074: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim
199.367  001.768  001.694: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/matchit.vim
199.466  000.028  000.028: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/matchparen.vim
199.564  000.033  000.033: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/netrwPlugin.vim
200.358  000.275  000.275: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/autoload/remote/host.vim
200.832  000.258  000.258: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/autoload/remote/define.vim
201.162  001.235  000.702: sourcing /Users/stephen/.local/share/nvim/rplugin.vim
201.173  001.499  000.265: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/rplugin.vim
201.392  000.142  000.142: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/shada.vim
201.552  000.063  000.063: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/spellfile.vim
201.734  000.035  000.035: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/tarPlugin.vim
201.837  000.025  000.025: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/tohtml.vim
201.956  000.047  000.047: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/tutor.vim
202.064  000.031  000.031: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/plugin/zipPlugin.vim
202.156  004.839: loading plugins
203.015  000.281  000.281: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/dashboard-nvim/plugin/dashboard.vim
203.859  000.070  000.070: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/spaceline.vim/autoload/spaceline/seperator.vim
204.065  000.680  000.610: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/spaceline.vim/plugin/statusline.vim
207.597  003.183  003.183: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/vim-devicons/plugin/webdevicons.vim
207.674  001.374: loading packages
207.873  000.199: loading after plugins
207.894  000.021: inits 3
210.725  002.831: reading ShaDa
213.104  000.139  000.139: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/spaceline.vim/autoload/spaceline.vim
213.429  000.098  000.098: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/spaceline.vim/autoload/spaceline/colorscheme/space.vim
213.755  000.067  000.067: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/spaceline.vim/autoload/spaceline/colors.vim
216.594  000.260  000.260: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/spaceline.vim/autoload/spaceline/syntax.vim
217.724  000.102  000.102: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/spaceline.vim/autoload/spaceline/diagnostic.vim
218.042  000.088  000.088: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/spaceline.vim/autoload/spaceline/file.vim
218.327  000.105  000.105: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/spaceline.vim/autoload/spaceline/vcs.vim
219.087  007.502: opening buffers
227.305  008.218: BufEnter autocommands
227.309  000.004: editing files in windows
227.764  000.236  000.236: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/dashboard-nvim/autoload/dashboard.vim
228.100  000.037  000.037: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/dashboard-nvim/autoload/dashboard/utils.vim
232.084  003.838  003.838: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/dashboard-nvim/autoload/dashboard/header.vim
232.645  000.160  000.160: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/dashboard-nvim/autoload/dashboard/section.vim
234.136  000.313  000.313: sourcing /usr/local/Cellar/neovim/HEAD-753a86c/share/nvim/runtime/autoload/provider/clipboard.vim
235.973  000.131  000.131: sourcing /Users/stephen/.cache/vim/plugins/pack/packer/start/dashboard-nvim/syntax/dashboard.vim
240.227  008.203: VimEnter autocommands
240.232  000.004: UIEnter autocommands
240.236  000.004: before starting main loop
242.844  002.608: first screen update
242.847  000.003: --- NVIM STARTED ---

Bootstrapping packer

I've seen several questions about how to do an unsupervised installation of neovim (not all specific to packer); a core question here is how to ensure from your init.vim that all your plugins are installed on a fresh system.

Vim-plug has this suggestion, and it would be nice to provide a similar snippet for packer.nvim that people can just put into their init.vim/init.lua. If there is something that can be implemented in neovim core to make this smoother, this might also be considered?

Ability to lock plugins

It may be desirable to prevent a plugin from updating; for example, if it follows APIs from neovim HEAD too closely and one doesn't want or is not able to update neovim itself (immediately). This could be done via a new lock option that keeps a plugin installed and managed (in contrast to disable), but skips it when sync() is called.

Plugin functions not available in init.vim

I have a problem where functions provided by plugins loaded via packer are not available from init.vim.

For example,

  1. nvim-lsp seems not to be loaded by the time that it's required in my lua/lsp.lua, which itself is required in my init.vim:
E5108: Error executing lua /Users/clason/.config/nvim/lua/lsp.lua:18: module 'nvim_lsp' not found:

This might be a problem with packages and lua in general, though.

  1. vimtex provides a function vimtex#toc#new, which I use to define customized tables of contents via a CreateTocs() vimscript function that is defined in my init.vim and then called as a file type autocommand for tex:
Error detected while processing function CreateTocs[1]..vimtex#toc#new:
line    1:
E121: Undefined variable: g:vimtex_toc_config
E116: Invalid arguments for function deepcopy
E116: Invalid arguments for function vimtex#util#extend_recursive
E116: Invalid arguments for function extend
E15: Invalid expression: extend( deepcopy(s:toc), vimtex#util#extend_recursive(   deepcopy(g:vimtex_toc_config
),   a:0 > 0 ? a:1 : {}))

My init.vim basically looks like

lua plugins = require('plugins') " lua/plugins.lua follows the readme and just calls use 'PLUGIN' without options
...
function CreateTocs()
  let g:toc_label = vimtex#toc#new({
        \ 'layers' : ['label'],
        \ 'show_help' : 0,
        \ 'show_numbers' : 0,
        \})
endfunction
au Filetype tex call CreateTocs()
...
lua require 'lsp' " lua/lsp.lua requires 'nvim_lsp' and does the usual server setup and on_attach config

I see from your dotfiles that these plugins are working for you -- what am I doing wrong?

Ubuntu bionic has a too old git

Output of :PackerSync and :PackerUpdate includes this for all my packages :

 ✗ Failed to update bakpakin/fennel.vim: {
  data = {
    data = {
      data = {
        exit_code = 129,
        output = {
          data = {
            stderr = { "error: unknown option `show-current'\nusage: git branch [<options>] [-r | -a] [--merged | --no-merged]\n   or: git branch [<options>] [-l] [-f] <branch-name> [<start-point>]\n   or: git branch [<options>] [-r] (-d | -D) <branch-name>...\n   or: git branch [<options>] (-m | -M) [<old-branch>] <new-branch>\n   or: git branch [<options>] (-c | -C) [<old-branch>] <new-branch>\n   or: git branch [<options>] [-r | -a] [--points-at]\n   or: git branch [<options>] [-r | -a] [--format]\n\nGeneric options\n    -v, --verbose         show hash and subject, give twice for upstream branch\n    -q, --quiet           suppress informational messages\n    -t, --track           set up tracking mode (see git-pull(1))\n    -u, --set-upstream-to <upstream>\n                          change the upstream info\n    --unset-upstream      Unset the upstream info\n    --color[=<when>]      use colored output\n    -r, --remotes         act on remote-tracking branches\n    --contains <commit>   print only branches that contain the commit\n    --no-contains <commit>\n                          print only branches that don't contain the commit\n    --abbrev[=<n>]        use <n> digits to display SHA-1s\n\nSpecific git-branch actions:\n    -a, --all             list both remote-tracking and local branches\n    -d, --delete          delete fully merged branch\n    -D                    delete branch (even if not merged)\n    -m, --move            move/rename a branch and its reflog\n    -M                    move/rename a branch, even if target exists\n    -c, --copy            copy a branch and its reflog\n    -C                    copy a branch, even if target exists\n    --list                list branch names\n    -l, --create-reflog   create the branch's reflog\n    --edit-description    edit the description for the branch\n    -f, --force           force creation, move/rename, deletion\n    --merged <commit>     print only branches that are merged\n    --no-merged <commit>  print only branches that are not merged\n    --column[=<style>]    list branches in columns\n    --sort <key>          field name to sort on\n    --points-at <object>  print only branches of the object\n    -i, --ignore-case     sorting and filtering are case insensitive\n    --format <format>     format to use for the output" },
            stdout = {}
          },
          err = {
            stderr = {},
            stdout = {}
          }
        },
        signal = 0
      },
      msg = "Error checking current branch for bakpakin/fennel.vim: fb50175 "
    },
    msg = "Error pulling updates for bakpakin/fennel.vim: "
  },
  msg = "Error checking updated commit for bakpakin/fennel.vim: fb50175"
}

From navigating the manual page it looks like --show-current is only for 2.23+ and I have 2.17 currently on this machine

Some edge cases leading to cryptic errors

Hi, thanks for the great plugin manager!

I found a few rough edges where the user "falls through" to Packer internals, leading to cryptic errors. Hopefully this report is helpful in future development.

System details

uname -orsv output: Linux 5.8.0-2-amd64 #1 SMP Debian 5.8.10-1 (2020-09-19) GNU/Linux

Packer commit: 237a134d5144f9f99df1a2f5bb29950c3d0ed795

nvim --version output:

NVIM v0.5.0-746-gf7cc3ae0b Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include Compiled by travis@travis-job-14258239-027b-4892-8d10-88b6f65b3f23

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

system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "
/home/travis/build/neovim/bot-ci/build/neovim/build/nvim.AppDir/usr/share/nvim
"

Run :checkhealth for more info

Problem 1: quitting Packer too fast?

When I run nvim +PackerCompile +PackerUpdate +qall, I get a bunch of the following error repeated over and over:

Error executing vim.schedule lua callback: .../nvim/pack/packer/opt/packer.nvim/lua/packer/display.lua:130: Expected 4 arguments

Removing +qall (i.e. not immediately closing Neovim) eliminates this. Maybe there needs to be some kind of special-case check in place for this.

Note: the error only appears for PackerUpdate and not PackerInstall. I tried adding +'sleep 1' to the command line before +qall but that didn't change the result.

Problem 2: invalid cmd option

When the cmd option in packer.use is not a valid command (In this case I wrote cmd = ':Foo' instead of cmd = 'Foo'), the following error appears:

Error detected while processing /home/nms/.config/nvim/plugin/packer_compiled.vim:                               
line  172:                                                                                                       
E183: User defined commands must start with an uppercase letter

Hopefully there's a better way to handle such a situation in the compiled plugin script. It's not that hard for an experienced Vim user to go into the compiled source and figure out what's wrong, but it's still not an ideal way to report the error.

Problem 3: unknown or private Github repo

I wrote 'Shougo/denite.vim' instead of 'Shougo/denite.nvim' by accident. Then the command :PackerInstall completely froze, printing the Git "enter username" prompt at the top of the Packer window. I had to gracelessly close my terminal tab, I couldn't get Vim or the shell to respond any other way. I have not tried to replicate this in a GUI frontend.

As with Problem 2, I'm not sure how to fix the user experience here. An experienced Git user (who is also observant enough to notice that the top line of the window has changed) has certainly seen this prompt before, so it's not hard to infer the source of the shell hanging. But this is still quite a nasty error to encounter.

Detail keybinding in update display not working with table

Since the last refactor/improvement, pressing enter on an updated plugin in the list no longer shows the specific commits in that update. (It's a bit hard to test since it relies on actual changes in plugins.)

I suspect that this is due to the fact that I pass the plugins as a single table to the new startup function?

Here's the relevant lua code:

vim.cmd [[packadd! packer.nvim]]
vim._update_package_paths()

local plugins = {
  {'wbthomason/packer.nvim', opt = true},
  'lervag/vimtex',
  {'nvim-treesitter/nvim-treesitter', opt = true},
}

local config = {
  display = {
    open_cmd = '25new [packer]',
  }
}

return require'packer'.startup {plugins, config = config}

Update not working in WSL

|| [packer] Error in coroutine: ...k/packer/opt/packer.nvim/lua/packer/plugin_types/git.lua:203: attempt to index field 'output' (a nil value)
|| [packer] Error in coroutine: ...m/site/pack/packer/opt/packer.nvim/lua/packer/update.lua:70: attempt to index local 'r' (a nil value)

I can investigate this some more later, not sure why this is happening.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.