wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.75k stars 261 forks source link

Packer v2 Rewrite #1042

Open wbthomason opened 1 year ago

wbthomason commented 1 year ago

This is a WIP PR to complete the first stage of this roadmap, at least through the load function.

Current progress:

The next steps are:

Contributions to this PR are welcome!

wbthomason commented 1 year ago

Tagging @akinsho, @EdenEast, anyone else interested in contributing to the rewrite.

akinsho commented 1 year ago

@wbthomason thanks for opening it, looks good 👍🏿. I was thinking I'd raise some PRs against this to help move it on, but will probably start with smaller things like adding Emmy Lua annotations to as many places as possible. I personally heavily rely on those when writing Lua, so would be nice if the types in the code base were clearer.

I've also been using the lazy loading pattern popularized by TJ in https://github.com/tjdevries/lazy.nvim and thought I might add it here? It defers the requiring of modules till they are actually indexed, so you can require all modules at the top of a file, but they won't actually be required till they are used. You can then combine this with sumneko's @module syntax to keep the type information, e.g.

local lazy = require('packer.lazy')
--- @module 'packer.config'
local config = lazy.require('packer.config')

Primarily because you've talked about reducing the cost of requiring packer, so this should help.

wbthomason commented 1 year ago

Oh, brilliant! That looks quite useful. Separately, more annotations is also a great way to start - that's a stated goal of the rewrite and will make working with the codebase substantially nicer. Thanks!