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

Implement keymapping helpers #222

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Implement keymapping helpers #222

wants to merge 3 commits into from

Conversation

dbarnett
Copy link
Contributor

Implements maktaba helpers for programmatically managing vim key mappings (as in the :map command) in maktaba#keymapping# and maktaba#keymappingspec#.

Usage examples:

call maktaba#keymapping#Map(',=b', ':FormatCode<CR>', 'n')
call maktaba#keymappingspec#Spec(',=b', ':FormatCode<CR>', 'n')
    \.WithArgs(['<silent>', <buffer>']).Map()

See keymapping.vroom and :help maktaba.KeyMapping for details.

Resolves #221.

@dbarnett dbarnett requested a review from malcolmr March 23, 2020 19:37
Copy link
Member

@malcolmr malcolmr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Sorry for the long delay!

autoload/maktaba/keymappingspec.vim Show resolved Hide resolved
autoload/maktaba/keymapping.vim Outdated Show resolved Hide resolved
autoload/maktaba/keymapping.vim Outdated Show resolved Hide resolved
vroom/keymapping.vroom Outdated Show resolved Hide resolved
vroom/keymapping.vroom Outdated Show resolved Hide resolved
autoload/maktaba/keymapping.vim Show resolved Hide resolved
autoload/maktaba/keymapping.vim Show resolved Hide resolved
autoload/maktaba/keymapping.vim Outdated Show resolved Hide resolved
" does one thing immediately and then a different follow-up behavior on another
" keystroke.
"
" For example, this defines a mapping that immediately unfolds one level but
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really surprised that this works, but we have tests, so sgtm!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, actually it looks like I had a typo in the args there I just fixed.

@dbarnett
Copy link
Contributor Author

dbarnett commented Nov 8, 2020

I'd held off on merging this PR for a while because

  1. The "full" implementation was surprisingly complex (vs. the simpler hack I originally found https://github.com/dbarnett/dotfiles/blob/8c9dc859db/.vimrc#L310) and I was hoping to find ways to reduce the scope a bit, and
  2. I'd seen a few quirks in the meantime while trying it out that I was hoping to troubleshoot further.

I'm still looking into those, but went ahead and submitted some fixes and resolved review comments while I'm looking at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement #mapping#MapUntilTimeout
3 participants