68 lines
2.2 KiB
Markdown
68 lines
2.2 KiB
Markdown
# Installing lazy
|
|
Lazy is one of packet managers for neovim, which is implemented and configured
|
|
in lua.
|
|
This snippet installs lazy via git cloning it to stdpath data from the github
|
|
reposity.
|
|
The path data specifies the neovim directory inside the directory specified by
|
|
variable *XDG_DATA_HOME*, which defaults to `$HOME/.local/share`.
|
|
|
|
I.e the default directory is $HOME/.local/share/nvim.
|
|
```lua
|
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
|
-- lazy.nvim installieren (falls nicht vorhanden)
|
|
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
|
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
|
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
|
if vim.v.shell_error ~= 0 then
|
|
vim.api.nvim_echo({
|
|
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
|
{ out, "WarningMsg" },
|
|
{ "\nPress any key to exit..." },
|
|
}, true, {})
|
|
vim.fn.getchar()
|
|
os.exit(1)
|
|
end
|
|
end
|
|
-- Add lazy.nvim directory to the path lua path.
|
|
vim.opt.rtp:prepend(lazypath)
|
|
```
|
|
|
|
|
|
## Sourcing plugins
|
|
When adding following line:
|
|
```lua
|
|
require("lazy").setup("plugins")
|
|
```
|
|
|
|
Lazy will source all lua files found in the source directory plugins.
|
|
|
|
The neovim config folder is: `$XDG_CONFIG_HOME`/nvim/, where *XDG_CONFIG_HOME*
|
|
defaults to `$HOME/.config/`.
|
|
I.e. the resulting directory which should exist is:
|
|
`$HOME/.config/nvim/lua/plugins`.
|
|
|
|
For simplicity each file in the directory should contain only one plugin.
|
|
|
|
## Adding plugins
|
|
Adding plugins is simple. Usually there is a example on the github page.
|
|
But with this approach you need to add a `return` in front of the object
|
|
and store the the into a new file.
|
|
For example:
|
|
```lua
|
|
return {
|
|
"NeogitOrg/neogit",
|
|
dependencies = {
|
|
"nvim-lua/plenary.nvim", -- required
|
|
"sindrets/diffview.nvim", -- optional - Diff integration
|
|
|
|
-- Only one of these is needed.
|
|
"nvim-telescope/telescope.nvim", -- optional
|
|
"ibhagwan/fzf-lua", -- optional
|
|
"echasnovski/mini.pick", -- optional
|
|
},
|
|
};
|
|
```
|
|
This will return the shown object.
|
|
|
|
For further explanation and documentation consult the documentation of lazy.
|