feat: smart lazy-loading + no forced setup#115
Conversation
fb8b6d2 to
1e972f4
Compare
| @@ -51,10 +52,10 @@ FFF.nvim requires: | |||
| build = "cargo build --release", | |||
There was a problem hiding this comment.
| build = "cargo build --release", | |
| build = "cargo build --release", | |
| -- Prevent lazy.nvim from lazy loading plugin | |
| lazy = false, |
Would it make sense to add this to the suggested plugin spec?
There was a problem hiding this comment.
I don't use lazy.nvim, so I don't know for sure. But I believe adding keys = ... makes it lazy-load? Not sure if setting lazy = false overrides that?
I could also put the keymap example in a separate code block that uses vim.keymap.set.
There was a problem hiding this comment.
Hmm I'm also not sure keys would make it lazy load again, even when lazy = false is specified.
At least for default.config.lazy it seems to get overriden by keys according to this page: https://lazy.folke.io/spec/lazy_loading
There was a problem hiding this comment.
Maybe the safe way would really be to set lazy = false and then use vim.keymap.set in a config() function inside the plugin spec
There was a problem hiding this comment.
lazy-loading isn't bad. It's just redundant.
But I do think using vim.keymap.set is a better example, as it also works for users of other plugin managers.
There was a problem hiding this comment.
I've added an init with vim.keymap.set.
Note: I chose init over config, because if you use config, lazy.nvim won't automatically pass the opts to the setup function.
3f48dbd to
c28dfff
Compare
|
Sorry for the long response—I had a very busy week. I tested it out, and it appears to be working, although the lazy sync never actually started before the picker is open. Perhaps I'm missing something? Also, I (and I believe most lazy users) prefer setting up the plugin using |
c28dfff to
33a7681
Compare
|
No problem 😄
Should be fixed in the latest commit. I tripped over the
Okay, I've reverted the lazy.nvim example modification to use the
I'm not sure how that would work? |
Closes #114
I've tested this by adding the plugin's nix flake output to my nvim config.
Things done:
require('fff').setup(config)andvim.g.fff = config.The config is validated the first time it is requested internally via
require('fff.conf').get().attempt to index nil valueerror when opening the picker.lazy_sync = falsein the config.UIEnter(this is equivalent to initializing on lazy.nvim'sVeryLazyevent).plugin/script. The commandsrequirefff's Lua modules lazily, so this has less startup overhead than would be needed to create lazy-loading configurations with lazy.nvim.