๐ Introduction
Alright! If you've been following along, we've configured some options and keymaps.
Next, we're going to use lazy.nvim!
It has:
- ๐ค Auto-magic lazy loading
- ๐ Lock files to keep track of plugin versions
- ๐ช Modular plugin structure
- ๐ฎ ... and more!
๐ HOWTO: Bootstrap.
It's quite easy to bootstrap lazy.nvim
Create a new module named lazy.lua
and SLAM this code in it.
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
Just that!
Now quit Neovim (if you can) and, start it back again. It should automatically install lazy.nvim.
โ Question of the day!
Q. ๐คจ How do I install plugins?
A. Just follow this crash course!
require("lazy").setup(plugins, opts)
plugins
would be an table of plugins and, opts
would be a table of options.
ok kthxbye/
I meant...
Crash course vII: Install the catppuccin colorscheme.
I love catppuccin. So let's get some mocha!
Create a new directory in lua
named plugins
. And in /plugins/
make a new module named colorscheme.lua
So, our file thing should look like:
~/.config/nvim/
โโโ init.lua
โโโ lua/
โโโ core/
โ โโโ init.lua
โ โโโ options.lua
โโโ keymaps/
โโโ movement.lua
โโโ ...
โโโ plugins/
โโโ colorscheme.lua
โโโ ...
In colorscheme.lua
it should look like:
return {
"catppuccin/nvim"
}
This code should be self-explanatory but, I'll give you a "high level overview" of it.
It returns a table.
Whoo! Now in lazy.lua
replace whatever I gave you (replace("lazy").setup(...)
) with...
require("lazy").setup({
{ import = "plugins" }
})
Now we're all done! Now let's go get a cup of mocha.
In our setup/init.lua
...
-- Some code here...
vim.cmd.colorscheme "catppuccin"
Now it should show the beautiful catppuccin theme! Let's actually get a cup of mocha now!
(Quick plug: here)
kthxbye :wq
Top comments (4)
Hi. Thank you for the good article. Is it possible to add some vim options (i.e.
vim.o.nu
) in a file inplugins
folder instead of at root level (akainit.lua
file)?Yes, I think so. As long the vim table is accessible, you can set Neovim options anywhere in your Lua code, including in plugin files. So, it should be possible to set Neovim options like vim.o.nu in a file located in the plugins folder. (TL;DR: it should be, as long the
vim
table is accessible, which should be the case)And how do we do that? Why not starting from the beginning?
Sorry for my slow response (being 2 months late is no excuse)
But, I've did start from the beginning here