Closed BlueDrink9 closed 4 years ago
I think the issue is in mapping them after nvim-R starts. When mapping them in the vimrc before or after calling Plug#end()
(using vim-plug
to manage plugins), the plug mappings do work. Mapping them in a function called after nvim-R loads, however, does not work.
The output of map q
is identical for working and not working mappings.
Actually, calling the function once vim loads, but before starting nvim-R, also doesn't work. Calling the function in the vimrc does work. Calling the function from au VimEnter *
does not work.
Calling from autocmd sourcepre
and sourcepost
does work, with both *
and r.vim
Calling on bufread
and bufreadpost
works. bufenter
does not. UIEnter
does not. winenter
does not.
Calling as a -c
arg doesn't work.
By 'not working' I mean the mapping is created, but does nothing.
The documentation (section Custom key bindings) says:
After changing the maps in your vimrc, you have to restart Vim.
But actually there a minor bug in RViewDF and I'm going to fix it now.
But I'm not changing them in my vimrc, I'm setting them in vim! Otherwise it's impossible to set
All maps are created with the <buffer>
argument.
Note: I'm very busy and have almost no spare time to maintain my projects on Github. When someone opens an issue about something that is working for many years, my first guess is that there is no bug at all and that the person has some configuration problem. So, instead of trying to fix a problem that I think doesn't exist, I simply wait until the user reports what he or she has managed to fix its configuration files. Maybe the problem is caused by another plugin. Did you try to disable all other plugins?
I can't understand your issue. I know that you are trying to change mappings, but the maps are customizable since about 2013. So, could you, please, better explain the context of your problem?
Ok, that's understandable. If nothing has changed, I'll check my config more thoroughly, although I don't know where else to look. But yes, as mentioned, I have done a minimal reproduction.
Yes. Maps created with the <buffer>
arg only act for the buffer they are created in. Therefore creating them in vimrc
normally will only create them for the first buffer loaded. In my case, after loading an R
file, I do
:nmap <buffer> q <Plug>RClearConsole
, then pressing q does nothing. The same happens with other nvim-R vimrc
with just vim-plug and nvim-R. If I put the mapping in my vimrc
, it works but cannot be buffer-local.
When you say "maps are customizable", does nvim-R have a custom way to set up maps just for R
files? Or is an autocmd the recommended way?
I hope this helps you understand my question. I appreciate your time
It's not a good idea to start mappings in Normal mode with regular letters because they all are already mapped to something. This is the reason why all Nvim-R's key bindings start with <LocalLeader>
. For example, q
is the first of two keys to start recording what will be typed next. Please, see:
:h recording
You should not use the argument <buffer>
when defining what sequence of keys should trigger a function:
nmap q <Plug>RClearConsole
You can customize Nvim-R's key bindings only in the vimrc.
So to clarify, you don't support users remapping nvim-R's <Plug>
commands in a buffer-local fashion, without using <localleader>
? I assume that is a limitation of the CreateMapping
function you use?
If this is the case, I think it would be good to create a feature-request issue for it. This wouldn't be for you to fix, but for future maintainers to consider.
Other repos allow more specific customisation, without requiring the use of localleader
. For example, if I have a neoterm 'send line to repl' mapping on <leader>ss
, the current system with nvim-R prevents me from overriding that with a R
buffers only. Does that use-case make sense?
It's not a good idea to start mappings [...]
That's the purpose of customization, wouldn't you agree? Let the user make this choice.
In this case, I don't actually use q
, but <c-p>
(which I don't have use for as a default map.) q
is what I was using for simplicity of debugging.
I'm sorry, but I really don't have time for this issue. Please, feel free to open another issue and wait until someone can help you.
I've reproduced minimally in terms of vimrc.
:nmap q <Plug>RClearConsole
, then pressingq
doesn't seem to do anything. No errors, either, so the plug mapping exists. This works in minimal repro.RSendMotion
doesn't work, even in minimal repro.\m
does.nmap <LocalLeader>vd <Plug>RViewDF
is the same.The mapping clearly exists:
:map q
When I set
verbose=99
and doqw
on a letter, nothing is output.Manually mapping it to what
\m
is set to works.