Nvim :help
pages, generated
from source
using the tree-sitter-vimdoc parser.
" List all runtime dirs and packages with Lua paths. :echo nvim_get_runtime_file("lua/", v:true)
% mkdir -p ~/.local/share/nvim/site/pack/foo % cd ~/.local/share/nvim/site/pack/foo % unzip /tmp/foopack.zipThe directory name "foo" is arbitrary, you can pick anything you like.
pack/foo/README.txt pack/foo/start/foobar/plugin/foo.vim pack/foo/start/foobar/syntax/some.vim pack/foo/opt/foodebug/plugin/debugger.vimOn startup after processing your config, Nvim scans all directories in 'packpath' for plugins in "pack/*/start/*", then loads the plugins.
% mkdir -p ~/.local/share/nvim/site/pack/foo/start/foobar % cd ~/.local/share/nvim/site/pack/foo/start/foobar % unzip /tmp/someplugin.zipYou would now have these files:
pack/foo/start/foobar/plugin/foo.vim pack/foo/start/foobar/syntax/some.vimFrom here it works like above.
:packadd
command::packadd foodebugThis searches for "pack/*/opt/foodebug" in 'packpath' and will find ~/.local/share/nvim/site/pack/foo/opt/foodebug/plugin/debugger.vim and source it.
:packadd! foodebugThe extra "!" is so that the plugin isn't loaded if Nvim was started with --noplugin.
:colorscheme
, are found below
"pack/*/start" and "pack/*/opt", you could put them anywhere. We recommend
you put them below "pack/*/opt", for example
"~/.config/nvim/pack/mycolors/opt/dark/colors/very_dark.vim".
:packadd
. E.g. depending on the compiler
version:if foo_compiler_version > 34 packadd foo_new else packadd foo_old endifThe "after" directory is most likely not useful in a package. It's not disallowed though.
:packadd
.
start/foobar/plugin/foo.vim " always loaded, defines commands start/foobar/plugin/bar.vim " always loaded, defines commands start/foobar/autoload/foo.vim " loaded when foo command used start/foobar/doc/foo.txt " help for foo.vim start/foobar/doc/tags " help tags opt/fooextra/plugin/extra.vim " optional plugin, defines commands opt/fooextra/autoload/extra.vim " loaded when extra command used opt/fooextra/doc/extra.txt " help for extra.vim opt/fooextra/doc/tags " help tags
mkdir ~/.local/share/nvim/site/pack cd ~/.local/share/nvim/site/pack git clone https://github.com/you/foobar.git myfoobarHere "myfoobar" is a name that the user can choose, the only condition is that it differs from other packages.
:packadd! fooextraYou could add this packadd command in one of your plugins, to be executed when the optional plugin is needed.
:helptags
command to generate the doc/tags file. Including this
generated file in the package means that the user can drop the package in the
pack directory and the help command works right away. Don't forget to re-run
the command after changing the plugin help::helptags path/start/foobar/doc :helptags path/opt/fooextra/doc
call foolib#getit()pack/foo/start/two/plugin/two.vim
call foolib#getit()pack/foo/start/lib/autoload/foolib.vim
func foolib#getit()This works, because start packages will be searched for autoload files, when sourcing the plugins.
$XDG_DATA_HOME/nvim/site/pack/core/opt
. Plugin's subdirectory name matches
plugin's name in specification. It is assumed that all plugins in the
directory are managed exclusively by vim.pack
.
git
executable of at least
version 2.36. Target plugins should be Git repositories with versions as named
tags following semver convention v<major>.<minor>.<patch>
.
vim.pack.add({
-- Install "plugin1" and use default branch (usually `main` or `master`)
'https://github.com/user/plugin1',
-- Same as above, but using a table (allows setting other options)
{ src = 'https://github.com/user/plugin1' },
-- Specify plugin's name (here the plugin will be called "plugin2"
-- instead of "generic-name")
{ src = 'https://github.com/user/generic-name', name = 'plugin2' },
-- Specify version to follow during install and update
{
src = 'https://github.com/user/plugin3',
-- Version constraint, see |vim.version.range()|
version = vim.version.range('1.0'),
},
{
src = 'https://github.com/user/plugin4',
-- Git branch, tag, or commit hash
version = 'main',
},
})
-- Plugin's code can be used directly after `add()`
plugin1 = require('plugin1')
add()
call.
version
. Let's say, plugin
named 'plugin1' has changed to vim.version.range('*')
.
vim.pack.update({ 'plugin1' })
.
version
set to current commit hash.
You can get it by running vim.pack.update({ 'plugin-name' })
and yanking
the word describing current state (looks like abc12345
).
version
set to whichever version you
want it to be updated.
kind
- one of "install" (install on disk), "update" (update existing
plugin), "delete" (delete from disk).
spec
- plugin's specification with defaults made explicit.
path
- full path to plugin's directory.
{src}
(string
) URI from which to install and pull updates. Any
format supported by git clone
is allowed.
{name}
(string
) Name of plugin. Will be used as directory name.
Default: src
repository name.
{version}
(string|vim.VersionRange
) Version to use for install and
updates. Can be:
nil
(no value, default) to use repository's default
branch (usually main
or master
).
{specs}
, {opts}
) vim.pack.add()src
into name
subdirectory (via git clone
) and update state to match version
(via git checkout
).
version
can be not the one actually
present on disk. Execute vim.pack.update() to synchronize.
{specs}
((string|vim.pack.Spec)[]
) List of plugin specifications.
String item is treated as src
.
{opts}
(table?
) A table with the following fields:
{load}
(boolean
) Load plugin/
files and ftdetect/
scripts. If false
, works like :packadd!
. Default
true
.
{names}
(string[]
) List of plugin names to remove from disk. Must
be managed by vim.pack, not necessarily already added to
current session.
table[]
) A list of objects with the following fields:
{path}
(string
) Plugin's path on disk.
{names}
, {opts}
) vim.pack.update()force
:
false
, show confirmation buffer. It lists data about all set to
update plugins. Pending changes starting with >
will be applied
while the ones starting with <
will be reverted. It has special
in-process LSP server attached to provide more interactive features.
Currently supported methods:
gO
via lsp-defaults or
vim.lsp.buf.document_symbol()) - show structure of the buffer.
K
via lsp-defaults or
vim.lsp.buf.hover()) - show more information at cursor. Like
details of particular pending change or newer tag.
Execute :write to confirm update, execute :quit to discard the
update.
true
, make updates right away.
{names}
(string[]?
) List of plugin names to update. Must be managed
by vim.pack, not necessarily already added to current
session. Default: names of all plugins added to current
session via vim.pack.add().
{opts}
(table?
) A table with the following fields:
{force}
(boolean
) Whether to skip confirmation and make
updates immediately. Default false
.