nvim-lua / wishlist

A public catalogue of Lua plugins Neovim users would like to see exist
MIT License
235 stars 0 forks source link

Translating vim macros to lua functions to enable debugging them #45

Open matu3ba opened 2 years ago

matu3ba commented 2 years ago

What? Debugging vim macros is outright painful, because they may silently abort without knowledge to user where and due to what reasons. Macros can not be executed step by step, so any workaround would be helpful. The workaround of how to debug vim macros is to translate it into vim functions: "The pain of converting to a function is only worth it if you use it a lot.". Why not use the simpler language lua instead and automatize the process? Related discussion.

Why?

  1. Make macros inspectable, reusable and store them as plain lua instead of invalid UTF8.
  2. Semiautomatically generate lua code from key actions.
  3. Generate the lua code from motions on code to generate refactoring snippets to share
  4. (crazy idea) Translate code back to vim motions.

Potential existing implementations: No, the state of debugging vim macros is poor as can be seen from the issues.

*Potential pitfalls:* Yes, this is depending on fixing the core (keymap) event handling infrastructure of vim. See this attempt to show inbuilds and this closed issue of vim. The other dependency is the completion of the necessary metadata.