Closed lewis6991 closed 1 year ago
We could take this further and make cond
the only way to lazy load and just provide the existing handlers as utility functions:
local loader = require'packer.loader'
packer.add{
{'my/plugin',
cond = {
loader.keys('n', 'ga'),
loader.cmd('mycmd'),
loader.event('CursorHold'),
function(load_plugin)
... -- my custom loader
end,
},
},
}
Didn't get a chance to post my review before merge (which is fine), but:
cond
the basis of all the lazy-loads - this also makes it easier to extend the set of loaders with community contributions. I think we'd want to play with the API to avoid cluttering specs with a bunch of loader.foo
calls, though, which could be done either by supporting the current keys and just calling the appropriate loader creation function while processing a spec (my personal preference), or a solution based around community convention (e.g. "always have local keys = loader.keys
, etc. at the top of your spec file")
@wbthomason