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

Clean up mappings: LocalLeader, Plug, and noremap #55

Merged
merged 6 commits into from Nov 7, 2013

Conversation

idbrii
Copy link
Contributor

@idbrii idbrii commented Mar 23, 2013

This is a set of changes to convert vim-ipython to use common vim plugin conventions:

  • Use LocalLeader for ftplugins - so users can define filetype-specific and global mapleaders.
  • Use <Plug> mappings so all mappings can be defined by users (even ones that use <SID> functions). This makes it easier to make internal changes (like renaming python functions) without breaking user's mappings.
  • Use noremap where possible. Ensures that plugin commands run as expected. As far as I understand, you can't use noremap when mapping to Plug, but maps that start with Plug will never evaluate to a user's sequence of keys, so that shouldn't be a problem.

I tried to break it up into small changes to make the diffs easier to read.

pydave added 6 commits March 23, 2013 08:55
Use <LocalLeader> for filetype-specific maps so user-defined local
leaders work. Recommended by :help maplocalleader
Use noremap where possible to prevent breakage when users remap certain
keys. (Some people swap : and ; which would break all calls to :python)
Using noremap will ensure maps still work for users who remap core vim
keys (like :).

Some maps only make sense in normal mode, so only map them there.
Use <Plug> for plugin maps to make it easier for users to define their
own maps.

<Plug> names are wrapped in braces to ensure that RunLine and RunLines
aren't considered overlapping by vim. (Otherwise, vim will pause after
RunLine to make sure you don't want RunLines.) See also:
    http://stackoverflow.com/questions/13688022/what-is-the-reason-to-parenthesize-plug-map-names

Plug names have common prefixes (Plot, RunLine) to make completion
easier and grouping clearer.

Note: You cannot use noremap for Plug (it won't map to anything).
Adds <buffer> to all plugin maps.

Only apply the maps in the current buffer to prevent them from carrying
over into nonpython buffers (where the commands wouldn't make sense).
Hide these from users since they are currently unimplemented.
@Bercio
Copy link

Bercio commented Sep 18, 2013

This is a great improvement, makes the plug-in much more configurable and reliable, and less intrusive. It's also more compliant to Vim mappings standards. Why hasn't it been accepted yet @ivanov ? (Lovely work, btw, I'm very thankful for your plugin, sorry for the maybe annoying comments, I just want to help make it even better!)

@ivanov
Copy link
Owner

ivanov commented Nov 7, 2013

thank you for these, @pydave, and to @Bercio for pinging me again about them. these look great to me, merging

ivanov added a commit that referenced this pull request Nov 7, 2013
Clean up mappings: LocalLeader, Plug, and noremap

closes #35
@ivanov ivanov merged commit 929ab1a into ivanov:master Nov 7, 2013
@idbrii idbrii deleted the vim-mappings branch November 9, 2014 23:50
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.

None yet

3 participants