nvim_runtime_lua

vim.pack

Methods5

function M.add(specs: string | vim.pack.Spec[], opts: vim.pack.keyset.add | nil) -> nil

Add plugin to current session

  • For each specification check that plugin exists on disk in |vim.pack-directory|:
  • If exists, check if its src is the same as input. If not - delete
  • immediately to clean install from the new source. Otherwise do nothing.

  • If doesn't exist, install it by downloading from src into name
  • subdirectory (via partial blobless git clone) and update revision to match version (via git checkout). Plugin will not be on disk if any step resulted in an error.

  • For each plugin execute |:packadd| (or customizable load function) making
  • it reachable by Nvim.

Notes:

  • Installation is done in parallel, but waits for all to finish before
  • continuing next code execution.

  • If plugin is already present on disk, there are no checks about its current revision.
  • The specified version can be not the one actually present on disk. Execute |vim.pack.update()| to synchronize.

  • Adding plugin second and more times during single session does nothing:
  • only the data from the first adding is registered.

Parameters
specsstring | vim.pack.Spec[]

List of plugin specifications. String item is treated as src.

Returns
nil
function M.update(names: string[] | nil, opts: vim.pack.keyset.update | nil) -> nil

Update plugins

  • Download new changes from source.
  • Infer update info (current/target revisions, changelog, etc.).
  • If force is false (default), show confirmation buffer.
  • If force is true, make updates right away.

Notes:

  • Every actual update is logged in "nvim-pack.log" file inside "log" |standard-path|.
  • It doesn't update source's default branch if it has changed (like from master to main).
  • To have version = nil point to a new default branch, re-install the plugin (|vim.pack.del()| + |vim.pack.add()|).

Confirmation buffer ~

The goal of the confirmation buffer is to show update details for the user to read, confirm (execute |:write|) or deny (execute |:quit|) the update.

Pending changes starting with > will be applied while the ones starting with < will be reverted.

There are convenience buffer-local mappings:

  • |]]| and |[[| to navigate through plugin sections.

Some features are provided via LSP:

  • 'textDocument/documentLink' - compute links for plugin paths, sources,
  • commits, and tags. Makes a best effort educated guess about a link structure. Use |gx| to open a link to an object at cursor.

  • 'textDocument/documentSymbol' (gO via |lsp-defaults| or |vim.lsp.buf.document_symbol()|) -
  • show structure of the buffer.

  • 'textDocument/hover' (K via |lsp-defaults| or |vim.lsp.buf.hover()|) - show more
  • information at cursor. Like details of particular pending change or newer tag.

  • 'textDocument/codeAction' (gra via |lsp-defaults| or |vim.lsp.buf.code_action()|) - show
  • code actions relevant for "plugin at cursor". Like "delete" (after extra confirmation for active plugins), "update" or "skip updating" (if there are pending updates).

Parameters
namesstring[] | nil

List of plugin names to update. Must be managed by |vim.pack|, not necessarily already added to current session. Default: names of all plugins managed by |vim.pack|.

Returns
nil
function M.del(names: string[], opts: vim.pack.keyset.del | nil) -> nil

Remove plugins from disk

Parameters
namesstring[]

List of plugin names to remove from disk. Must be managed by |vim.pack|, not necessarily already added to current session.

Returns
nil
function M.get(names: string[] | nil, opts: vim.pack.keyset.get | nil) -> vim.pack.PlugData[]

Gets |vim.pack| plugin info, optionally filtered by names.

Parameters
namesstring[] | nil

List of plugin names. Default: all plugins managed by |vim.pack|.

Returns
function M._get_names(skip_inactive: nil | boolean) -> plugin_names string[]

Fields1

M._plugin_lock_path : string