-
Notifications
You must be signed in to change notification settings - Fork 127
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
RCreateMaps: Create plug mappings unconditionally (fixes #470, fixes #494) #472
Conversation
The option |
It doesn't change the behavior of that option, unless I'm forgetting something. As before, the creation of mappings is independent of user_maps_only. The only change that might affect users is that now, if a user has mapped to a mapping, the default mapping is still created. But that wasn't ever affected by user_maps_only anyway. If you still think that change breaks compatibility, I think a new option would make more sense than re-using the other option. Something like Again I understand you are very busy, so happy to just implement the new option if you are unsure. Or, if there is another contributer you trust, tag them to review. The changes aren't urgent, but naturally I'd like them merged this week if possible. I do want to emphasise that I think the current behavior is undocumented and inconsistent with the behavior of most other plugins. |
@jalvesaq if you have time, could you please respond to the above and suggest how to move forward with this PR? |
This plugin is a file type plugin. Their maps must be available only for the file types that it supports. It doesn't make sense to have two maps for the same action. |
Regarding your point about maps being only available for file types they support: That's what this PR allows. Under the current model, |
@jalvesaq are you able to respond to my previous comment, or would you like something else clarified or fixed? |
I don't remember who has proposed the use the |
Ok, I understand, thank you for the response. I will continue using my fork for now. Would it help you (when you get time) for me to assemble examples of other plugins' use of |
Would it help you (when you get time) for me to assemble examples of other plugins' use of `<plug>` mappings?
Yes, please.
|
Here is my list, I hope it helps convince you that the way nvim-R does it is non-standard, and that this pull request does not ask for abnormal behavior. First up is vimtex, a popular (2.5k stars) latex plugin.
Plugin author Luc Hermitte uses them here:
And hopefully the nail in the coffin, the Vim sources themselves declare their Also, adding |
I'm trying Nvim-R from your repository. Now, there a delay of about half a second to send lines to R. I have this in my init.vim:
|
Can you also tell me the result of That sort of delay usually happens because you have something else mapped to |
The output is:
|
Ok, I'll have a look when I have more time and see if I can reproduce it, or see what might be causing it. It definitely doesn't appear if you keep the same init.vim but with your nvim-R instead of mine? |
Oh, is your localleader also I can change that behaviour to still not define the default mapping if there is a |
My local leader is comma.
That was what I did. I renamed my Nvim-R directory and cloned yours.
Yes. |
Just tried to understand this PR and it seems @BlueDrink9 has a point, according to
I'm gonna try out this PR to see if I can reproduce a delay. |
Giving the PR a go, everything seems to work fine, such as the default |
I can reproduce this using space with this minimal rc: git clone https://github.com/BlueDrink9/Nvim-R.git /tmp/nvim-r
nvim -u NORC --cmd 'set rtp+=/tmp/nvim-r' -c 'nmap <space> <Plug>RDSendLine' -c 'call StartR("R")' test.r Personally, baffled as to why. |
Previously, Plug mappings were only created if they were already in use - i.e., if someone had mapped them to something in their .vimrc. The problem with that is if someone wants to create buffer-local maps to an nvim-R <Plug> mapping, they cannot do so from .vimrc. They must do so once the buffer is loaded - ie within vim, after loading .vimrc. This is usually done with an filetype autocmd. See jalvesaq#470 for more
The word 'stop' is a bit misleading, because it suggests killing the R process totally. That doesn't always happen, it just interrupts.
@jalvesaq this is now done. Figured out what's causing it, although I'm not sure why, since it seems like bizarre vim behaviour. Since this fork now defines all plug mappings even if not in use, there are 3 plug mappings that start with the same thing: call RCreateMaps('ni0', 'RDSendLine', 'd', ':call SendLineToR("down")')
call RCreateMaps('ni0', 'RDSendLineAndInsertOutput', 'o', ':call SendLineToRAndInsertOutput()')
call RCreateMaps('v', 'RDSendLineAndInsertOutput', 'o', ':call RWarningMsg("This command does not work over a selection of lines.")') Deleting the second two of these solves the problem. Haven't got more time to look into it now, but I'm pretty sure that this isn't the intended behavior with |
maps to We need to check whether manually creating two |
Sorry @jalvesaq for the long message. I hope my writing is clear and understandable. I have confirmed that it is in fact standard vim behavior. 3 The de-facto way to avoid this is to surround the mapping name in brackets. In this case, the fix would look like a single change in mapping: call RCreateMaps('ni0', '(RDSendLineAndInsertOutput)', 'o', ':call SendLineToRAndInsertOutput()')
call RCreateMaps('v', '(RDSendLineAndInsertOutput)', 'o', ':call RWarningMsg("This command does not work over a selection of lines.")') That brings us to a cross-roads that requires @jalvesaq to choose, however. I will make an argument for why it should be changed, probably to the second solution above. I don't think the impact would be too large, because if something breaks, a poweruser will come straight to the repo to look for the cause or complain. We could pin an issue highlighting the change and highlight it in the commit log and/or the readme, so that they see the change. This is why it needs to be changed. The people that don't notice this problem, and use I think the tradeoff is well-worth making some users update their config |
I'm much in favour of this PR since well justified by @BlueDrink9 . Also learned an awful lot along the way. I've just updated the this PR an haven't experienced any problems yet, but will keep testing. |
I've just tried Nvim-R from your repository again and still there is a delay when sending lines with my custom key binding ( So, I'm thinking about doing the following:
In this way, I can maintain more than one style of defining key bindings (currently, I don't want to do this) and the user could install other scripts maintained by other people which would define the key bindings in a different way. What do you think about this proposal? |
It doesn't seem like the ideal solution, and like you say it introduces a lot of extra code. The suggestions I made would fix it and bring it in line with vimscript standards. I hadn't changed my repository version, because I was waiting on your response to my last comment. I have changed it now, so please try again. The delay should be gone. |
Thanks! I did only a very quick test and there was no delay anymore. So, I merged it. |
Previously, Plug mappings were only created if they were already in use - i.e., if someone had mapped them to something in their
.vimrc
.The problem with that is if someone wants to create buffer-local maps to an nvim-R mapping, they cannot do so from .vimrc.
They must do so once the buffer is loaded - ie within vim, after loading .vimrc. This is usually done with an filetype autocmd.
This PR fixes that by making Nvim-R's
<Plug>R*
mappings always available, matching the behavior of most plugins that define maps.