brainfucksec / neovim-lua

Neovim KISS configuration with Lua
GNU General Public License v3.0
826 stars 116 forks source link

Breaking Change - New Plugin Manager: lazy.nvim #27

Closed brainfucksec closed 1 year ago

brainfucksec commented 1 year ago

As of today (Feb. 25, 2023) lazy.nvim is used as the plugin manager instead of packer.

See commit: 2db1c38

Details

Old package: packer.nvim

New package: lazy.nvim

Directories

Changing the plugin manager involves changing the directory structure of Neovim.

Old Neovim directory structure with packer:

${HOME}/.config/nvim/

nvim/
├── lua
│   ├── core
│   │   ├── autocmds.lua
│   │   ├── colors.lua
│   │   ├── keymaps.lua
│   │   ├── options.lua
│   │   └── statusline.lua
│   ├── lsp
│   │   └── lspconfig.lua
│   ├── plugins
│   │   ├── alpha-nvim.lua
│   │   ├── indent-blankline.lua
│   │   ├── nvim-cmp.lua
│   │   ├── nvim-tree.lua
│   │   └── nvim-treesitter.lua
│   └── packer_init.lua
├── plugin
│   └── packer_compiled.lua
└── init.lua

Files to be removed:

~/.config/nvim/lua/packer_init.lua
~/.config/nvim/plugin/packer_compiled.lua

New Neovim directory structure with lazy.nvim:

nvim/
├── lua
│   ├── core
│   │   ├── autocmds.lua
│   │   ├── colors.lua
│   │   ├── keymaps.lua
│   │   ├── lazy.lua
│   │   ├── options.lua
│   │   └── statusline.lua
│   ├── lsp
│   │   └── lspconfig.lua
│   └── plugins
│       ├── alpha-nvim.lua
│       ├── indent-blankline.lua
│       ├── nvim-cmp.lua
│       ├── nvim-tree.lua
│       └── nvim-treesitter.lua
├── init.lua
└── lazy-lock.json

Note: Update the init.lua file with the instruction for load lazy configuration file:

-- init.lua 
-- Import Lua modules
  require('core/lazy')
  require('core/autocmds')
  require('core/keymaps')
  require('core/colors')
  require('core/statusline')
  require('core/options')
  require('lsp/lspconfig')
  require('plugins/nvim-tree')
  require('plugins/indent-blankline')
  require('plugins/nvim-cmp')
  require('plugins/nvim-treesitter')
  require('plugins/alpha-nvim')

New lazy.nvim files:

lazy-lock.json
/lua/core/lazy.lua

The lazy.lua is the configuration file, is very similar to packer_init.lua and makes it easy to migrate, see: https://github.com/folke/lazy.nvim#-migration-guide

The lazy-lock.json is automatically created when you run lazy.nvim for the first time, is the file with the git package information of the installed plugins, see: https://github.com/folke/lazy.nvim#-lockfile-lazy-lockjson

Installed plugins folder

The directory where the installed plugins are located will also change:

Old directory with packer:

${HOME}/.local/share/nvim/site/pack/packer/

New directory with lazy.nvim:

${HOME}/.local/share/nvim/lazy/

Advices

It is recommended to back up the current configuration with packer.nvim before doing the migration, in this way you have a fallback copy of a working Neovim configuration.

e.g.:

Backup of Neovim config and plugins directory with cp:

cp -Rv ${HOME}/.config/neovim /mybackups/neovim-backup_packer
cp -Rv ${HOME}/.local/share/nvim/site/pack/packer /mybackups/neovim-backup_packer/plugins

Backup with rsync:

rsync -ahv --progress ${HOME}/.config/neovim /mybackups/neovim-backup_packer
rsync -ahv --progress ${HOME}/.local/share/nvim/site/pack/packer /mybackups/neovim-backup_packer/plugins

Before using lazy.nvim you should read the information on how to do this, see: https://github.com/folke/lazy.nvim

For any questions and help you can comment on this section where I will try to help you with the migration (which is not difficult anyway). :)

PaideiaDilemma commented 1 year ago

Cool :) I have already migrated, but will adapt the suggested new layout with /lua/core/lazy.lua.

brainfucksec commented 1 year ago

Cool :) I have already migrated, but will adapt the suggested new layout with /lua/core/lazy.lua.

Thanks :)

RainerKuemmerle commented 1 year ago

Use lazy update here: https://github.com/brainfucksec/neovim-lua/blob/main/nvim/lua/plugins/alpha-nvim.lua#L46

Thanks for providing the awesome template.

tsrattan commented 1 year ago

Hi i migrate. Everything is running fine. on statusline when I press : it still displays NORMAL instead of COMMAND. Thanks

brainfucksec commented 1 year ago

Use lazy update here: https://github.com/brainfucksec/neovim-lua/blob/main/nvim/lua/plugins/alpha-nvim.lua#L46

Thanks for providing the awesome template.

Thanks, I have already updated the indicated command, thanks again for highlighting it :)

See: commit 8701098

brainfucksec commented 1 year ago

Hi i migrate. Everything is running fine. on statusline when I press : it still displays NORMAL instead of COMMAND. Thanks

Strange, I don't see error with : command:

2023-03-12_322x92

Please if you have problems on the statusline you should open a dedicated issue where I can follow up with you.