Friendship ended with Packer

I wasn’t me who abandoned the relationship!

The other day I was tweaking my nvim config and wondered if there was a packer update. I checked github and found this:

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:

And the Packer’s author [pronoun]self has switched to Lazy.nvim

I’m fine with some good old legacy softwares, but not with a legacy software manager that still has 300+ open issues! And there are breaking changes(mostly good ones) with every neovim major release. I have to hop – and the migration surprisingly straightforward. And I took the chance to refactor my config.

Now lazy.nvim is my best friend!

My (new) config is hosted at https://github.com/shrik3/schnitzel.nvim

I’m not gonna write in details how I migrate because it was pretty trivial

Maybe you can take away this:


Create a new file lua/lazy.lua, and put this is init.lua

1
require "lazy"

In lua/lazy.lua

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
vim.g.mapleader = " "

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)
require('lazy').setup('plugins')

The last line suggests lazy to traverse the directory lua/plugins and load plugin related config therein. Note that you need to define your key before any plugin gets included.

Then create lua/plugins/init.lua and name your plugins here

return {
    "folke/which-key.nvim",
    { "folke/neoconf.nvim", cmd = "Neoconf" },
    "folke/neodev.nvim", 

    -- name your plugins here --
    'shrik3/alabaster.nvim',
    'shrik3/vim-aspectcpp',
}

But I suggest you only list here those who need no additional setup or configs, otherwise name and configure them in separate files under lua/plugins! see below:

Here is a template for a single plugin: lua/plugins/xyz.lua

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
local M = {
    'author/xyz',
    dependencies = {
        'author/plugindep'
    },
}

M.config = function()
    require("xyz").setup({
        -- configs for the plugin
    })
end

return M

For me the file structure looks like this (tree .config/nvim/lua):

.
├── init.lua                 -- main neovim config
├── lazy.lua
└── plugins
    ├── bufferline.lua
    ├── comment.lua
    ├── init.lua
    ├── lspconfig.lua
    ├── lualine.lua
    ├── markdown_and_tex.lua
    ├── neotree.lua
    ├── nvim-cmp.lua
    ├── startify.lua
    ├── telescope.lua
    ├── template.txt
    └── toggleterm.lua
created 22.09.2023
EOF
[+] click to leave a comment [+]
the comment system on this blog works via email. The button
below will generate a mailto: link based on this page's url 
and invoke your email client - please edit the comment there!

[optional] even better, encrypt the email with my public key

- don't modify the subject field
- specify a nickname, otherwise your comment will be shown as   
  anonymous
- your email address will not be disclosed
- you agree that the comment is to be made public.
- to take down a comment, send the request via email.

>> SEND COMMENT <<