Godot-proposals: Add a Vim mode to the script editor

Created on 26 Sep 2017  Â·  49Comments  Â·  Source: godotengine/godot-proposals

It would be great to have Vim style editing in the editor, because it's a really fast way to edit code. I would like to help developing it, but I don't know where to start.

editor

Most helpful comment

Personally, I believe the best possible implementation of this is to follow the Language Server Protocol. https://microsoft.github.io/language-server-protocol/

This would create a better experience in VSCode, Atom, Vim, Emacs, and any other LSP compatible editor.

All 49 comments

I second that wish.
I started to go the other direction :)
https://twitter.com/StateOffGames/status/962590588494385152

Please, bois, support vim! Vim is life!

Vim mode or support would be great, but until then using VSCode with the Vim and Godot Tools extensions works pretty well.

I have to say, I have almost never used a Vim mode that came even close to replicating my workflows and productivity in Vim itself, and I would imagine most Vim users would agree with this sentiment. I honestly don't think adding a Vim mode to the official editor would make sense unless they used an existing embedded editor like Ace that already has a field-tested implementation that they could enable with just a flag, because otherwise we would never be happy with it and always want more.

I use (neo)vim for Godot, and even if they added a Vim mode that would never change. If anything I would rather they spend time improving workflows with external tools.

As a contrasting opinion, as a person who primarily uses the JetBrains IDEA flavour of IDEs, I am completely accustomed to just using Vi mode (IDEAVim). Not because the mode is better than vim, but because it works well enough with just the basic editing bindings, buffers, searching, and macros. It's just the basic muscle-memory, deep-ingrained features that I need. Beyond that, the editor/IDE has features for more advanced stuff that is specific to the problems being solved.

Honestly, I just want to be able to use the Godot editor without needing the arrow keys. If it means I end up implementing it myself when I have more time, then so be it.

Yes, I'm a JetBrains IDE user too. Just some basic features would be enough.

Personally, I believe the best possible implementation of this is to follow the Language Server Protocol. https://microsoft.github.io/language-server-protocol/

This would create a better experience in VSCode, Atom, Vim, Emacs, and any other LSP compatible editor.

ohh man this would be so nice. please do.

This would be greatly appreciated!

The first thing I do in any IDE or editor is install a Vim hotkey plugin. If an editor doesn't have one, I typically find myself moving on to something else pretty quick! It would be excellent to have Vim hotkey support in the Godot script editor. For the time being, we'll have to make due jumping between Godot and another editor...

Why not just writing gdscript with vim or other editors with Vim mode supported? I don't think this kind of feature is supposed to support for a general game engine.

@Geequlim Because the auto completion doesn't work as nicely as in Godot. Or doesn't work at all.

I have to say, I have almost never used a Vim mode that came even close to replicating my workflows and productivity in Vim itself, and I would imagine most Vim users would agree with this sentiment.

I use Vim regularly and will say that while I agree, all "vim mode" implementations in IDEs across the board are lacking in the feature set that makes Vim amazing, the sheer amount of mouse usage I find myself doing in Godot is staggering for me. Simple Vim bindings for getting around the file without using a mouse, visual select mode for copying things, etc, are all still much better than none at all.

I'm personally not very into exiting the Godot editor to use an external IDE, and would much prefer to stay in the zone in Godot editor but have some of the basic Vim functionality.

Has there been any actual code work on implementing this?

Supported now? Seems so long time passed...

Supported now? Seems so long time passed...

It's currently not supported.

Transferred to the proposal repo. The OP does not include the new issue template, this would need to be retrofitted or added by a new comment.

I think there is no need for this feature anymore. I'm using the language server with Visual Studio Code (with vim plugin) and the experience is amazing.

Supported now? Seems so long time passed...

Interestingly, when nobody is working on a feature it doesn't get done. I have some spare time (as with the rest of the world) but this little project is still not quite at the top of my todo list.

I think there is no need for this feature anymore. I'm using the language server with Visual Studio Code (with vim plugin) and the experience is amazing.

Disagree. For many people (myself included) keeping the number of windows/applications to a minimum is an important part of the IDE user experience.

I think there is no need for this feature anymore. I'm using the language server with Visual Studio Code (with vim plugin) and the experience is amazing.

Agreed. LSP was a _huge_ game changer. I use (neo)vim and my workflow is exactly what I wanted.

I will throw my hat into the "This is still a desirable feature" camp

I think there is no need for this feature anymore. I'm using the language server with Visual Studio Code (with vim plugin) and the experience is amazing.

Agreed. LSP was a _huge_ game changer. I use (neo)vim and my workflow is exactly what I wanted.

@AnderRasoVazquez @rosshadden
Does the language server support debugging? That's the only thing I have been unable to integrate to an external editor.

Neovim can be embedded in any editor with all plugins and settings. I think it can be easier and more powerful that just vim emulation.

@npit This should be feasible. See https://github.com/godotengine/godot-vscode-plugin/pull/165 which implemented debugging support in the VS Code extension.

I agree that VSCode with the language server provides a really great stand-in for this feature, but not when it comes to writing shaders. The autocomplete for shaders in-editor is some of the best I've seen and it's too much to leave behind just for vim navigation. So I still find myself wishing for either editor vim or VSCode shader autocomplete.

Adding Neovim to Godot would be an amazing feature that would benefit the workflow of countless users to come, both old and new. I am only 23 years old yet I use Neovim for more than 80% of my workflow.

I heard about godot few days ago and this is the first thing I searched for after opening it. I always end up typing kkkkk or jjjjjjj in the editor ;(

Using godot's editor feels like using notepad to code. Bring vim to godot please.

@aganm Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.

I have been exploring this idea today. I am new to Godot's code base, so would love any input anyone can provide.

It looks like scene/gui/text_edit is the main control responsible for text editing in Godot. I made a module that registers my own version of TextEdit and it did override the built in one. So it seems like shipping a vim Godot module that people could load via LD_LIBRARY_PATH might be a passable solution?

As for the vim functionality itself, libvim looks promising. It's the engine that drives OniVim2, and it's basically vim distilled down to a simple C library. If it's good enough for OniVim2, I'd bet it's good enough for getting vim-isms into Godot.

A huge downside is this would completely re-implement TextEdit and thus basically be a fork of it. Might find it necessary to continually pull in changes from the main TextEdit to keep the vim TextEdit control working as Godot evolves.

Anyway, I am currently poking at this and seeing how feasible this is. If anyone has any input or ideas, would love to hear them. I'm very early in this, so unsure how doable this really is.

The Godot developers gave their thoughts on Vim mode in the July 2020 Q&A: https://www.youtube.com/watch?v=k5DKlhMy5wQ&t=63m25s

"Is Godot Editor going to have a Vim mode anytime?"

@groud: This is quite something we will... the problem is that kind of feature is like, Vim, is a complex program, so basically like a Vim mode... I'm not even sure what it means.

@akien-mga: I mean it's... it has been requested a lot and I think there is two things, maybe you want Vim movement and OK we can implement that, should not be too hard to implement a way where you can move with the same keys as in Vim and like press I to be able to insert code and then no longer know how to get out of the script editor, that's definitely something we can implement, it's really easy to trap you in a tool. But implementing all the features of Vim, there is no point. Like if you want the full Vim power then you should use Vim. There's with the Godot GDScript Language Server protocol you can use Vim and have like all the features that you have in the editor - autocompletion, debugging, and even documentation. So I think that if you are a Vim diehard then you should use that, if you just.

@Faless: Yeah I mean like if you like Vim and you like Vim for example just use Vim [instead] of trying to mimic it. It's Vim, it's great.

@reduz: Yeah one thing I said before but I want to repeat is that maybe there is a feature like this that for a very small amount of users it could be very interesting but maybe not for majority, maybe will not implement it because it doesn't make [a lot] of sense because it's a lot more code that needs to be maintained, that needs to be fixed, that needs to take a maintainer, and that just takes time so... that we don't really have because you have to understand that most Godot code is done with contributors donating their free time, but what we can do is just figure out which kind of extensions you would need for the editor or for the engine to be able to implement this, and then make a proposal or a pull request asking for this kind of extensions. So you can make a plugin that implements this functionality, and the editor gives you the extensions that you need to be able to do it. I think that's probably the best way in this kind of scenarios.

@groud: A simple [solution to] the problem would be to have a console directly inside the editor. That could work and I don't think it should be really complex to implement, [integrating] the terminal inside the editor, so if someone would want to use Vim directly in the editor or Emacs or Nano or any kind of terminal-working thing...

@akien-mga: Then I tell you: use Linux and use a dropdown terminal like Yakuake or Guake and then you can have your Vim on top of your Godot editor and code at the same time.

@groud: laughs That's another solution too.

To summarize the above, if you want Vim, you should use Vim, and Godot won't add a "full" Vim mode. If you want only specific features of Vim, or you need APIs in the Godot editor to allow for a third-party Vim plugin, then you can discuss that here.

They are right. Reinventing Vim inside the editor will be difficult to implement and maintain.
But I surprised that no one mentioned Neovim. It provides RPC API for editors to embed itself. For example, there is a plugin for VSCode. Such solution will be much easier to maintain and it will be "real" Vim with your configuration.

@Shatur95 Then Neovim could be added via an editor plugin, correct? Granted, you'll probably need to do some GDNative stuff since the engine doesn't have actual RPC support (the RPC support Godot offers seems to be a layer atop RPC, rather than RPC itself), but it would be possible to use Neovim as a editor plugin.

@LikeLakers2, yes. Despite the lack of RPC support, it will still be easier than writing Vim from scratch.

What I had in mind is what @akien-mga said.

maybe you want Vim movement and OK we can implement that, should not be too hard to implement a way where you can move with the same keys as in Vim and like press I to be able to insert code

I'd like to have at least the simple movement vim commands, no need for a full vim reimplementation. Without that, it means I have to use the mouse to code, which is pretty awful when you are used to vim navigation.

That being said, if we can have the full power of vim by using libvim mentionned by @city41 or RPC API mentionned by @Shatur95, that would be a delight.

In case I wasn't clear, I did not suggest implementing vim from scratch. That would be quite crazy :) libvim, libnvim and neovim RPC at a high level all do the same thing, off load the vim details to a third party.

I have libvim up and running in my module now, so far so good. I'm moving ahead because everything I am doing is external to Godot. If nothing else, it's just throw away work as a learning experience. But possibly it can also help move Godot towards a vim experience.

@city41 Perhaps you can publish your work so far? And is this something you could implement in GDNative?

@aaronfranke I have published it here: https://github.com/city41/Godot_VimTextEdit

The README is very thorough and explains pretty much everything.

I gotta say, doing ciw, u and shift+r and navigating with hjkl, etc from inside of Godot feels pretty darn good :)

is this something you could implement in GDNative?

Probably? I don't really know. I am new to Godot and have no GDNative experience yet.

Neovim's RPC is very powerful and would mean users could essentially use _their_ vim with _their_ config, not an implementation that happens to also be vim. In 2018 in this thread I said something about how even if Godot added a vim mode to its editor most vim users would still prefer to use our own editors. Two years later I would like to update that statement. If Godot embedded a Neovim instance I think a lot of us might actually use it.

As a practical example of this, I have been using firenvim for a couple weeks now in my browser (despite the name, it works in Chrome, and I am currently writing this comment with it). It uses my vim config, all of my mappings, all of my plugins... everything. If this same functionality were used in Godot as opposed to using libvim, in my mind it would go from some gimmicky feature to a very powerful experience. Or it could still be awful, but I would think of all the options mentioned here it by far has the best odds.

Here is a screenshot of me writing this comment:
2020-09-15-09-40-00

So, I've got to ask -- because I'm a little confused. If you feel you need to edit scripts using a vim-like editor, what's stopping you from just... opening them with Vim? You can even set a editor setting in Godot to make it open script files within Vim: https://docs.godotengine.org/en/stable/getting_started/editor/external_editor.html

So, I've got to ask -- because I'm a little confused. Godot's scripts are stored in plain text. If you feel you need to edit scripts using a vim-like editor, what's stopping you from just... opening them with Vim?

I think this was answered before:

@Geequlim Because the auto completion doesn't work as nicely as in Godot. Or doesn't work at all.

That said, I guess just embedding Neovim or something like that would have the same problem. You'd probably need to make some plugin to run within Vim to talk to Godot to get completion information &c.

And if that's the case, maybe the time would be better spent enabling Godot to run in some sort of LSP-mode so that it can be used as a backend for existing Vim (and other editor/IDE) plugins?

I don't know if Godot had a language server when that comment was made -- but as far as I'm aware, it has a language server now.

A quick Google search points to https://github.com/godotengine/godot/issues/34523, which was closed when https://github.com/godotengine/godot/pull/35864 was merged -- meaning that Godot should have a LSP-mode that could be used with Vim, so long as you have an appropriate Vim plugin.

@LikeLakers2, LSP works, but there is no debugger support. If you want to debug something you still need to use Godot built-in editor.

@Shatur95 Isn't DAP (debug adapter protocol) support being worked on?

There is a few plugins, such as nvim-dap and vimspector but they are experimental and I couldn't get them to work with Godot.

Even plugin for VSCode do not have good Godot DAP support (check issues).

That said, I guess just embedding Neovim or something like that would have the same problem. You'd probably need to make some plugin to run within Vim to talk to Godot to get completion information &c.

My TextEdit experiment has auto completion continuing to work as-is. I would suspect that to be true of a neovim based solution as well. Same with syntax highlighting.

Neovim's RPC is very powerful and would mean users could essentially use their vim with their config

the downside to nvim's RPC is it's significantly more complicated (although it is simplified with libraries such as libnvc). It would also likely lead to more people having problems as nvim versions come and go.

libvim is literally vim, so having it read your vimrc would be doable. Similarly, libnvim is literally nvim. I would prefer to investigate libnvim before neovim rpc, as libnvim is basically the "rpc" brought into the same process.

An embedded vim library means the entire experience stands on its own, which simplifies a lot of things.

Isn't DAP (debug adapter protocol) support being worked on?

Not actively, i.e., it was discussed, it's something we'd like to have, but
it's not being developed by anyone for what I know (contributions welcome!).

On Wed, Sep 16, 2020, 13:49 Hugo Locurcio notifications@github.com wrote:

@Shatur95 https://github.com/Shatur95 Isn't DAP (debug adapter
protocol) support being worked on?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot-proposals/issues/622#issuecomment-693353981,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAM4C3WADNGNHAINYMQQCX3SGCQ6LANCNFSM4LRVLRSA
.

I was trying qtcreator for the first time today. I'm used having to find a vim plugin for any ide I want to use, so I was pleased when I saw this
image

A simple checkbox transforms the editor into vim mode (☑ Use FakeVim). I think it's a good reference for what a vim mode in godot could look like.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

WilliamTambellini picture WilliamTambellini  Â·  3Comments

Xrayez picture Xrayez  Â·  3Comments

lupoDharkael picture lupoDharkael  Â·  3Comments

arkology picture arkology  Â·  3Comments

davthedev picture davthedev  Â·  3Comments