Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow lazy loading upon entering visual mode #29

Open
vi013t opened this issue Dec 8, 2024 · 6 comments
Open

feat: allow lazy loading upon entering visual mode #29

vi013t opened this issue Dec 8, 2024 · 6 comments

Comments

@vi013t
Copy link

vi013t commented Dec 8, 2024

lazy.nvim seems to respect visual-whitespace's /lazy.lua, which loads the plugin on BufEnter, and it seems like any event passed to lazy gets overridden by this.

visual-whitespace.nvim could be lazy-loaded upon entering visual mode with event = "ModeChanged *:[vV\x16]", which would load the plugin whenever the user enters visual, visual line, or visual block mode for the first time. This is preferable (in my opinion at least) because it keeps the plugin from being loaded until it's needed, which is generally the lazy.nvim convention.

I'd request that either event = "ModeChanged *:[vV\x16]" becomes the default load event to replace BufEnter in /lazy.lua (I believe this is a sensible default), or that lazy.lua just gets removed in favor of allowing the user to decide when the plugin gets loaded.

@vi013t vi013t closed this as completed Dec 8, 2024
@vi013t
Copy link
Author

vi013t commented Dec 8, 2024

Closing after seeing 3a10ba5

@mcauley-penney
Copy link
Owner

mcauley-penney commented Dec 8, 2024

I didn't even check if it was disallowing other events from being used, so that's my bad. I can reproduce this. I looked into alternative methods and it looks at the moment that I can successfully load on keys = { 'v', 'V', '<C-v>' } without the issue I was facing in the commit you linked.

Is this interesting as a default?

Edit: note to self for posterity, see #25

@mcauley-penney mcauley-penney reopened this Dec 8, 2024
@vi013t
Copy link
Author

vi013t commented Dec 8, 2024

Hmm, interesting idea. I guess in theory you might break compatibility for some users that remap any of those keys (?) but I imagine that's a very small percent given that they're Vim defaults for very common tasks.

If anything it'd be convenient if lazy.nvim let you override the event specified in a plugin's lazy.lua for those niche cases. That's more of an issue with lazy than visual-whitespace though.

Part of me wonders if just removing event from lazy.lua entirely would be a smart option so that users could tailor it to their liking, and doing something like putting your keys = { 'v', 'V', '<C-v>' } solution in the README under installation. It would cover those few edge cases, I guess.

Like I said though, I imagine those are far and few between, and I'm not even certain it'd mess up in those cases. So hey, whatever works I guess!

@mcauley-penney
Copy link
Owner

you might break compatibility for some users that remap any of those keys

That's true, I hadn't considered that.

Part of me wonders if just removing event from lazy.lua entirely would be a smart option so that users could tailor it to their liking, and doing something like putting your keys = { 'v', 'V', '' } solution in the README under installation. It would cover those few edge cases, I guess.

I also think this is the best option. I'm going to make this change today.

@mcauley-penney
Copy link
Owner

Update:

  1. I reverted the commits that added the lazy package spec
  2. I still need to either update the readme with the recommended means lazy loading or find another way

@mcauley-penney
Copy link
Owner

167f6d1 adds a line about lazy loading on keys to the Lazy configuration example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants