dbalatero / VimMode.spoon

Adds vim keybindings to all OS X inputs
691 stars 32 forks source link

custom keymapping for cursor hjkl keys #69

Open jernejFilipcic opened 3 years ago

jernejFilipcic commented 3 years ago

Would it be possible to make it customizable? Some of us use jkl; or (in my case, on a foreign keyboarfd) jklč for cursors, in order to let the index finger stay on j, where it belongs.

dbalatero commented 3 years ago

Can you sketch out the API you'd like to see for customizing?

jernejFilipcic commented 3 years ago

Hi! Vim and sublime's vim plugin use this syntax in the customization's files.

noremap č l noremap l k noremap k j noremap j h

Intellij's vim plugin just reads these mappings from the .vimrc file, so that would be the easiest way from the user's point of view.

On Wed, Dec 9, 2020 at 4:48 PM David Balatero notifications@github.com wrote:

Can you sketch out the API you'd like to see for customizing?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dbalatero/VimMode.spoon/issues/69#issuecomment-741860698, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALPIRX65RABJ3JTFUMINTH3ST6L53ANCNFSM4UTVH7MQ .

dbalatero commented 3 years ago

Some blockers/things to think about before we could really get started:

# what are all these??
:no[remap]  {lhs} {rhs}     |mapmode-nvo|   *:no*  *:noremap* *:nor*
:nn[oremap] {lhs} {rhs}     |mapmode-n| *:nn*  *:nnoremap*
:vn[oremap] {lhs} {rhs}     |mapmode-v| *:vn*  *:vnoremap*
:xn[oremap] {lhs} {rhs}     |mapmode-x| *:xn*  *:xnoremap*
:snor[emap] {lhs} {rhs}     |mapmode-s| *:snor* *:snore* *:snoremap*
:ono[remap] {lhs} {rhs}     |mapmode-o| *:ono* *:onoremap*
:no[remap]! {lhs} {rhs}     |mapmode-ic|    *:no!* *:noremap!*
:ino[remap] {lhs} {rhs}     |mapmode-i| *:ino* *:inor* *:inoremap*
:ln[oremap] {lhs} {rhs}     |mapmode-l| *:ln*  *:lnoremap*
:cno[remap] {lhs} {rhs}     |mapmode-c| *:cno* *:cnor* *:cnoremap*
:tno[remap] {lhs} {rhs}     |mapmode-t| *:tno* *:tnoremap*

This feels like a large amount of work to me, so it would be nice to have someone help do the initial thinking on all this.

jernejFilipcic commented 3 years ago

To be honest, I had to google what lua is, but judging from the example it should be fine, too.

As for recursion, map things are recursive, noremap are not. If you recursively map b to a and c to b, c will also be mapped to a. I don't think it is needed in this context. The letter before that tells you if the remapping works always or only in normal, insert, visual (etc.) mode. What we really need here is nnoremap j k (not recursive remapping in normal mode, by pressing j it does what k used to do) or noremap j k (same thing, but works also in visual mode). There is a nice tutorial on https://vim.fandom.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_1)

But anyway, a "map j motion-left; map č motion-right" thing would be good enough, in my opinion. Still, if somebody wants to use vim mode, he probably knows what a particular letter that he wants to remap does in vim

On Wed, Dec 9, 2020 at 6:47 PM David Balatero notifications@github.com wrote:

Some blockers/things to think about before we could really get started:

  • Currently I use an hs.hotkey.modal to handle key presses, which has hardcoded key bindings. We'd need something else instead that can dynamic shift around the key bindings.
  • I'm not that excited to get in the business of parsing vimrc files directly
  • Neovim has Lua native config now, with APIs like vim.api.nvim_set_keymap() (example https://www.reddit.com/r/neovim/comments/fq4p6m/map_directly_to_lua_function/). Is it worth drawing any inspiration from it?
  • The native remap API kind of sucks - instead of noremap l k I wish it was something more sane and readable like noremap l motion-up. I understand the desires to stay closer to Vim syntax and more native, but 30 years later is this truly the best way to express key maps?
  • I have no idea what all these remap commands do and I feel like I should understand it better before just diving in and adding my own key binding system. What possible footguns might I encounter? What is nnoremap vs noremap? I seem to recall recursion being a thing with the key bindings as well. Very confusing.

what are all these??

:no[remap] {lhs} {rhs} |mapmode-nvo| :no :noremap :nor :nn[oremap] {lhs} {rhs} |mapmode-n| :nn :nnoremap :vn[oremap] {lhs} {rhs} |mapmode-v| :vn :vnoremap :xn[oremap] {lhs} {rhs} |mapmode-x| :xn :xnoremap :snor[emap] {lhs} {rhs} |mapmode-s| :snor :snore :snoremap :ono[remap] {lhs} {rhs} |mapmode-o| :ono :onoremap :no[remap]! {lhs} {rhs} |mapmode-ic| :no! :noremap! :ino[remap] {lhs} {rhs} |mapmode-i| :ino :inor :inoremap :ln[oremap] {lhs} {rhs} |mapmode-l| :ln :lnoremap :cno[remap] {lhs} {rhs} |mapmode-c| :cno :cnor :cnoremap :tno[remap] {lhs} {rhs} |mapmode-t| :tno :tnoremap

This feels like a large amount of work to me, so it would be nice to have someone help do the initial thinking on all this.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dbalatero/VimMode.spoon/issues/69#issuecomment-741940352, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALPIRX7FYZ5DXJCSBZXZUUTST6ZZLANCNFSM4UTVH7MQ .