Vim mode
clouedoc opened this issue ยท 9 comments
Hi, your Golang playground is nice!
Would you consider adding support for Vim keybindings as an option to add in the settings menu?
@clouedoc I would definitely consider researching this! Also looking forward for contributions from community.
Afaik there is a VScode plugin for vim mode. Probably its a good place to start researching.
https://github.com/brijeshb42/monaco-vim - thoughts on testing this out and including it as a package dependency? Will test out locally
FYI - I did test it out and it seems to play nicely/not conflict with the go-playground instance of monaco editor. Obviously there's a cleaner way to do this but it seems to work just fine:
this.vimMode = initVimMode(
this.editorInstance,
document.getElementById("vimStatus"),
);
I'll hold off on any further development - thanks a ton for looking into this!
@fow5040 looks like I finished it. Had to add a lot of glue code on top of lib's glue code (because this lib is basically a big adapter on top of another lib) so I'm not 100% sure about stability.
I have other few things to do before shipping a new release, but it will be shipped in v1.11 soon.
Can I ask you to try to test the latest master
branch locally?
Gladly, thanks a ton!
@x1unix
Will test more later and tommorrow - for the most part it works fantastically! A few minor notes (and a nitpick)
Minor:
- Statusbar commands (i.e.
:%s/foo/bar/g
) are not dismissed upon pressing enter, unlike regular vim. Workaround is to press ESC after each command, but if easily fixable that would be ideal- Note: this only happens if a command succeeds. If a command fails, the window errors red and continues like normal.
:reg
(and I assume other commands that open a window/buffer) can't really be rendered on the small status bar. The Visual Studio Code vim plugin instead renders these in the command omnibar. I don't know of a good workaround for this, but as this is just a go playground I don't think this is a huge issue- Shift+L, Shift M, and Shift+H error out, but I personally don't use these very often
Nitpick
- I would reword this:
Allows to use Vim key bindings when editing
to thisAllows usage of Vim key bindings when editing
Lastly, I managed to abuse the vim plugin for a while and somehow got my editor into a "call stack exceeded" state where the whole editor stopped responding. Unclear if this was because of the vim plugin or some other sort of abuse I did, but I haven't been able to reproduce. Probably a symptom of gluing, and not a huge issue
As a disclaimer, while I work in vim most of the day, I am by no means a vim guru. Here are a handful of things I did test that seem to be working fine:
- General movement
- Visual, Visual Block mode + yank
- Vertical Typing (Visual Block + Shift i)
- Search (and replace)
- Registers (except for the visual issue when displaying via
:reg
) - Marks, i.e.
m a
' a
- Yank between symbols, i.e.
yi"
oryi(
- Ctrl+A number increment (why is this a thing? I don't know)
- Undo + Redo (
99u
works fine, impressive!)
All in all, considering this is a go playground and not necessarily a full fledged IDE, I think the state of the vim plugin is entirely usable in its current state (especially considering it's not enabled by default).
@fow5040 thank you for feedback. I'll add a fix for search and registry commands.
Unfortunately currently I can just implement a :reg
command readable output to status bar because I can't find any documentation regarding omnibar on monaco editor.
Maybe later I'll implement some better solution.