artisticat1 / obsidian-latex-suite

Make typesetting LaTeX as fast as handwriting through snippets, text expansion, and editor enhancements
MIT License
1.43k stars 56 forks source link

[FEATURE] Intercept Vim-triggered newlines for the Matrix environment `\\` shortcut #352

Open llakala opened 1 week ago

llakala commented 1 week ago

Description of the Problem

Currently, within a Matrix environment, a \\ symbol is inserted whenever you press Enter. However, if you have have Obsidian's Vim mode enabled, and press o to add a newline and enter Insert mode, no \\ is added.

Description of the Solution

Hypothetically, the plugin would be able to detect the Vim action and add \\ when pressing o, just like when pressing Enter normally.

I don't know if this is possible. If the newline isn't being detected by KeyboardEvent, I assume that Obsidian's does something like this when pressing o: 1) add the newline through its own systems, undetectable to us 2) enter Insert mode, where we can now detect inputs (but a bit late for that)

If it is possible to hook into this mechanism, it's not obvious to me how one would do it. I originally planned on making a PR to implement this, but realized I didn't know what direction to go in. I'd love some feedback on whether people think this would be possible, and if so, how it could be implemented.