Code Monkey home page Code Monkey logo

Comments (5)

kana avatar kana commented on May 23, 2024 1

Okay, I understand how the problem occurs.

What targets.vim does is at startup as follows:

  • Override a in both Visual and Operator-pending mode, to provide various features like aa, an(, and so on.
  • If a key sequence is not known to targets.vim, leave how to act for the key sequence to Vim.

What Arpeggio map sa ... does is as follows:

  • Override s and a in Normal, Visual and Operator-pending mode, to detect which keys are simultaneously pressed.
  • If a (or s) is not simultaneously pressed with another key, do the default action of a (via <Plug>(arpeggio-default:a)).

The problem is caused by both plugins trying to do "the default action" as a fallback.

When you typed caa, this key sequence is processed as follows:

  1. c is typed. It is an operator. Vim waits for another key in Operator-pending mode.
  2. a is typed. It is mapped by vim-arpeggio to detect which keys are simultaneously pressed. Vim waits for another key for a very short time.
  3. Since another key is not typed in the short time limit, vim-arpeggio treats the last a is solely typed. The a is mapped to <Plug>(arpeggio-default:a).
  4. <Plug>(arpeggio-default:a) is mapped to targets#e('o', 'a', 'a'), because you defined so.
  5. targets#e('o', 'a', 'a') is evaluated. targets.vim requires another key to decide what to do. So Vim waits for another key.
  6. a is typed. targets.vim knows how to handle aa. So it selects an argument. Operator-pending mode is now complete.
  7. c deletes the argument. Now Vim waits for another key in Insert mode.

But when you typed caw, this key sequence is processed as follows:

  1. c is typed. It is an operator. Vim waits for another key in Operator-pending mode.
  2. a is typed. It is mapped by vim-arpeggio to detect which keys are simultaneously pressed. Vim waits for another key for a very short time.
  3. Since another key is not typed in the short time limit, vim-arpeggio treats the last a is solely typed. The a is mapped to <Plug>(arpeggio-default:a).
  4. <Plug>(arpeggio-default:a) is mapped to targets#e('o', 'a', 'a'), because you defined so.
  5. targets#e('o', 'a', 'a') is evaluated. targets.vim requires another key to decide what to do. So Vim waits for another key.
  6. w is typed. targets.vim doesn't know how to handle aw. So it leaves aw to Vim with the following note: "Since aw might be mapped to another key sequence by user, aw must be remapped if possible".
  7. aw is in the typeahead buffer. Vim reads the first key from there. It is a. Vim have to remap a. And a is... mapped to the same stuff as (2).
  8. So (2)~(7) are repeated many times.
  9. Vim detects this remapping loop at some point, then halts the loop.

That's why caw results in "E223: recursive mapping".

from vim-arpeggio.

kana avatar kana commented on May 23, 2024

Hmm, it seems to be a tricky problem. I’ll look into it later.

from vim-arpeggio.

kana avatar kana commented on May 23, 2024

I've confirmed that the problem is reproducible on my Vim. Both plugins drastically redefines the default key mappings. So the problem seems to be very trickier than I thought. We have to know everything about how targets.vim works to describe the problem.

I'll continue to look into the problem later. But please don't expect too much about solving the problem.

from vim-arpeggio.

kana avatar kana commented on May 23, 2024

Note that both plugins do the right things. The problem is caused by combining both plugins.

vim-arpeggio provides the way to specify whether solely typed key should be remapped or not, but targets.vim doesn't so. The problem could be solved if targets.vim supports this feature. But it seems to be a hard problem.

from vim-arpeggio.

blasco avatar blasco commented on May 23, 2024

I've ended up finding a solution that should work everywhere, even outside of vim. I love the arpeggio/chord concept and I'm very grateful that you introduced to me via your plugin :)
I don't know why this concept is not more popular, its much better than the modifier keys such as shift or ctrl, it's a more generalized version of them.

I'll build/buy a programmable mechanical keyboard, which has a microcontroller within it, and I can configure it to do arpeggios (and also other cool things, like different functionality if you tap or hold a key)

https://github.com/qmk/qmk_firmware/blob/master/docs/feature_combo.md

I like this one, although its quite expensive:

https://ergodox-ez.com/

And there is also a build it your self version (I'm into electronics too)

https://www.reddit.com/r/MechanicalKeyboards/comments/fp9mxs/crkbd/
built with:
https://keyhive.xyz/shop/hotswap-corne-helidox
https://novelkeys.xyz/products/gmk-dots-gb

from vim-arpeggio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.