Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vim mode #103

Closed
clouedoc opened this issue Mar 1, 2022 · 9 comments · Fixed by #169
Closed

Vim mode #103

clouedoc opened this issue Mar 1, 2022 · 9 comments · Fixed by #169
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@clouedoc
Copy link

clouedoc commented Mar 1, 2022

Hi, your Golang playground is nice!

Would you consider adding support for Vim keybindings as an option to add in the settings menu?

@x1unix
Copy link
Owner

x1unix commented Mar 1, 2022

@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.

@x1unix x1unix added enhancement New feature or request help wanted Extra attention is needed labels Mar 14, 2022
@fow5040
Copy link

fow5040 commented May 8, 2022

https://github.com/brijeshb42/monaco-vim - thoughts on testing this out and including it as a package dependency? Will test out locally

@x1unix
Copy link
Owner

x1unix commented May 9, 2022

@fow5040 I'll take a look, thanks

@x1unix x1unix added this to the 1.11.0 milestone May 9, 2022
@x1unix x1unix added the in-progress Status: In Progress label May 9, 2022
@x1unix x1unix self-assigned this May 9, 2022
@x1unix x1unix removed the help wanted Extra attention is needed label May 9, 2022
@fow5040
Copy link

fow5040 commented May 9, 2022

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!

@x1unix
Copy link
Owner

x1unix commented May 9, 2022

@fow5040 thank you for pointing out to this lib. My implementation will be a bit more complex because I want to display vim status in the bottom status bar (like vscodevim does) and less DOM-coupled.

@x1unix x1unix mentioned this issue May 10, 2022
@x1unix
Copy link
Owner

x1unix commented May 10, 2022

@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?

#169

@fow5040
Copy link

fow5040 commented May 10, 2022

Gladly, thanks a ton!

@fow5040
Copy link

fow5040 commented May 10, 2022

@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 this Allows 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" or yi(
  • 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).

@x1unix
Copy link
Owner

x1unix commented May 10, 2022

@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.

image

Maybe later I'll implement some better solution.

@x1unix x1unix pinned this issue May 10, 2022
@x1unix x1unix removed the in-progress Status: In Progress label May 10, 2022
@x1unix x1unix added this to To do in Better Go Playground via automation May 10, 2022
@x1unix x1unix moved this from To do to Done in Better Go Playground May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

3 participants