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

Allow disabling mappings in insert or cmdline mode #48

Closed
wants to merge 1 commit into from

Conversation

hupfdule
Copy link

Introduces the following new options:

  • 'g:rsi_disable_in_insert_mode' to disable the mappings in insert mode.
  • 'g:rsi_disable_in_cmdline_mode' to disable the mappings in cmdline mode.

The diff of this PR is way larger than I would like it to be (as it basically just wraps a few lines with a check for the above mentioned settings). But the alternative would have been to wrap nearly each line separately, which in my opinion would be even worse.

This PR fixes #39 and #41. It is very similar to #26, but extends to all mappings, not only the Meta mappings.

With this patch I am able to use vim-rsi for insert-mode and readline.vim for command line mode.

Introduces the following new options:

- 'g:rsi_disable_in_insert_mode' to disable the mappings in insert mode.
- 'g:rsi_disable_in_cmdline_mode' to disable the mappings in cmdline mode.
@tpope
Copy link
Owner

tpope commented Nov 15, 2019

RSI's maps are by their very nature non-essential, so I think it would make sense if it always deferred to other maps. I'd accept something like the following:

function! s:Map(mode, flags, lhs, rhs) abort
  if empty(mapcheck(a:lhs, a:mode))
    exe a:mode . 'map <expr>' a:flags a:lhs a:rhs
  endif
endfunction

@tpope tpope closed this Nov 15, 2019
@hupfdule
Copy link
Author

While your suggestion would avoid overwriting existing mappings, I don't think it would fully resolve that problem of conflicting with readline.vim. That would only be possible if vim-rsi is loaded after readline.vim. Some plugin managers support such a thing, others don't. And when not using any plugin manager this is even harder to achieve.

Also it would not help if someone wanted to have readline-style keybindings only in command mode (like readline.vim does) or (less likely) the other way around.

Therefore I don't think I will make another PR with your suggestion. I can live with having my own fork of it.

Thank you for having a look into it!

@hupfdule
Copy link
Author

As @justinmk explicitly "dislikes" this PR I am a bit curious about what he dislikes about it…

@tpope
Copy link
Owner

tpope commented Nov 15, 2019

It will work regardless of load order assuming readline.vim doesn't also implement this behavior.

@hupfdule
Copy link
Author

Ah, I see.
If vim-rsi is loaded first, it will map these key and those will be overwritten later by readline.vim. If readline.vim is loaded first, it will not overwrite these mappings.

Still, this doesn't allow for a user to activate vim-rsi only in insert mode or only in commandline mode.

Nevertheless, I would be glad if you introduce this conditional mapping, but I think it is better if you do it yourself, since you know best how it fits into vim-rsi.

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

Successfully merging this pull request may close these issues.

enable only in command mode
2 participants