-
Notifications
You must be signed in to change notification settings - Fork 284
[WIP] (mini.clue) expose function to start a query #442
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
Conversation
|
Thanks for the PR! I can't exactly verbalize why I am not fond of the idea of exporting this function directly. The best guess is probably because I have a gut feeling that it will bring a lot of unexpected issues when used not in the way we anticipated. Like, for example, I am not sure what is the proper way to handle the case when this function is called but 'mini.clue' already called Having to update operator tweaking to me is another argument against this. I would better support I'll give it a closer look. |
Yeah, I can see this.
I don't exactly know why this is needed, but it was the only solution I found that worked in all cases. I played around with various modes of feedkeys and setting recursive to true. But this broke the tests. I think it has to do with having keys = '' as starting point.
What ways do you see to approach this? (efficiently or not, just to get some ideas)
Thanks! |
To be perfectly honest, my initial approach is to not support this at all. 'mini.clue' has somewhat fragile implementation due having to deal with a lot of Neovim internals. Adding more is troublesome. But at the same time I do see the appeal of having this functionality. Just not sure if it is worth it over adding a lot of new code.
Yes, this is the first idea that came to mind. One problem here is that triggers are set up per buffer and having new autocommand created per buffer might lead to a lot of autocommands lying around. This is ok for mappings because they are removed with buffer (as far as I understand), but not autocommands. Which means extra code for cleanup, etc.
I would advise against this, as updating 'mini.clue' code is indeed quite time consuming and complicated. I'll look into it myself. |
Ah, I see. I didn't really think about the need for them to be created per buffer. This makes it more complicated for sure.
Alright, thanks again! Let me know when I can help in any way. |
I just looked this up and found this part in the documentation. So maybe this makes it a little bit easier:
See: https://neovim.io/doc/user/autocmd.html#autocmd-buflocal |
|
Another obstacle for going forward with this is the fact that buffer-local autocommands are not allowed to use Not going to lie, chances for adding this continue to go down. I'll revisit it later, hopefully with new ideas. |
|
Are there any things that must be checked / done when using global autocommands for this? Like things that wouldn't be needed if the autocommands were buffer local? |
Not sure if there are (right now, at least). One thing I don't like about them being global is that it introduces the need to track them. This is needed to allow updating As a side note, I've tried "exporting |
That makes sense.
I just pushed a fix for those operators. They should now work as intended. I actually quite like the versatility of this approach. Another possible use case is setting up a mapping like this: I get your concerns though. |
|
I actually just stumbled on such a problem. This triggered mini.clue on entering operartor-pending mode and again when pressing i which led to strange behaviour. This at least could be prevented by removing all mini.clue related mappings in the current buffer directly when entering the query process and re-enabling them afterwards. Edit: Pushed a fix for it. Actually the trigger mapping hit when the first sequence was being executed. I now just disable all buffer local mappings before execution. |
7c1a17f to
6b831b0
Compare
ab2c595 to
4ee5bdb
Compare
|
I have pushed another iteration as a prototype. Notes on this one:
As far as i can tell everything seems to be working although some tests are still failing. I think that's because the autocommand is currently hardcoded and the tests probably need to be adjusted to the final implementation (if this should happen). It would be awesome if you could take another look when you got the time. |
Thanks for not loosing interest in this feature! I have looked at implementation and here are some thoughts:
To make it as explicit as possible, here are the requirements for this to be considered as a potential merge:
I know, this might be a bit strict, but 'mini.clue' did prove to be a very troublesome module with a lot of hidden edge cases. So better be overly cautious here. |
|
Thanks for your feedback. Just to clarify: I never intended this to be merged as is. This is why i referred to it as a prototype. I thought of it this way: The features using 0.10 would be completely optional. So when using nvim 0.9 or below a warning could be thrown instead of setting up the autocommands (like ''-type trigger need nvim 0.10 to work as inteded). Temporarily disabling all triggers was an additional safety measure to ensure there aren't any triggers Nonetheless i have reduced the changes to a minimum. The required code to use it in autocommands can be done outside like this: One thing i noticed: Using undo after e.g. >ip makes the cursor jump down a line. All existing tests still pass using nvim 0.7.2, 0.8.3, 0.9.1 and nightly. |
I don't really understand. If assumed most common use case for
I can't really reproduce this. Would you mind also posting the 'mini.clue' config? Its |
Okay, i get what you mean now. I thought of it as an additional feature you could make use of when you got 0.10. Otherwise the plugin would still work the same without it. Maybe vim.fn.state() isn't even needed here though. I just tested it without it and it seems to still work the same.
Interesting. I never noticed this with which-key but maybe i changed something else in my config. Need to check this later.
Sure thing |
6cc9b0a to
f39259a
Compare
|
A few more things i noticed / thought about:
I narrowed this down to being an issue with noice.nvim. Disabling it fixes this. |
f39259a to
3283ad1
Compare
|
After several times of getting back to this, I couldn't reach the state when I felt that this change worth the effort. Sorry for your time spent on this PR. Closing as not planned. |
|
Well, I had my fair share of fun exploring your plugin and discovering new options in neovim. I'll probably keep my fork around, so feel free to take a look if / when you'd like to try again. Thanks for taking the time to think about it! |
|
Thanks for the understanding! 🙏 |
Based on our discussion in #430 I came up with the following solution for my use case.
This was my proposal:
My Solution:
The trigger is now expected as a parameter. This allows one to setup triggers other than key mappings, for example this one:
I have not added tests or documentation yet, but would be willing to try where needed.
All existing tests where successful on the following builds of Neovim:
Just let me know what you think about this solution in general or any changes you would like to see.