idbrii / unity-vimeditor

Add vim to the Unity's External Tools section in Preferences so all your files open in gvim.
MIT License
18 stars 8 forks source link

Linux NeoVim and Vim support #3

Open Skunkynator opened 3 years ago

Skunkynator commented 3 years ago

As gvim has a few problems, and there is users that use NeoVim I request support for Vim and NeoVim

Because these do not handle opening the terminal on their own, the Plugin would need to start the terminal emulator, which gives the possibility of giving an option to the user, which terminal emulator they want to use. They also do not support the "--servername" option, which is not a major problem

these are temporary, local changes i did in the VimExternalEditor.cs file to only support NeoVim for now:

line 84 : "nvim",
line 363: start_info.FileName = "/bin/konsole";  //this string can point to any terminal emulator of choice
line 380: file = Path.Combine(Application.dataPath, file);
line 396: start_info.Arguments = $"-e \"{GetVimEditorPath()} +{line} \\\"{file}\\\"\"";
idbrii commented 3 years ago

I request support for Vim

Vim should work if it gets added to k_executable_names. Even now, if you have gvim installed too, you could start vim with vim --servername Unity and when you open something from Unity it should open in that vim session.

and NeoVim

Neovim plans to restore --servername et al: https://github.com/neovim/neovim/issues/1750

Until then, there's this wrapper: https://github.com/mhinz/neovim-remote So we could add support for nvr.

I think sending commands to neovim via a vim-compatible wrapper is fine, but opening and managing a terminal is beyond the scope of this plugin. Does konsole close when nvim quits? In retrospect, a "fill in the blanks" plugin would be more broadly useful (to support any editor or terminal), but I think Unity requires you to have an executable path.

If you don't use gvim, then you could add a script gvim in your PATH that opens konsole and nvim and sends files to it. You should be able to do that without modifying VimExternalEditor?

Skunkynator commented 3 years ago

Vim should work if it gets added to k_executable_names.

It does not as vim on its own does not handle the terminal emulator

Does konsole close when nvim quits?

It does, as the terminal that is launched using the "-e" option will execute the next command and close as soon as the command is done executing

If you don't use gvim, then you could add a script gvim in your PATH that opens konsole and nvim and sends files to it. You should be able to do that without modifying VimExternalEditor?

I did not think of that, tho that is quite a workaround imho, but it could work so ill consider doing that.

My main problems with vim in unity are

  1. The project files not regenerating
  2. Vim/NeoVim not being opened in a terminal emulator.

Both of these problems are solved in 2 separate plugins (this one and Unity3dVim) which do not work together Whereas this one is the more up to date and fletched out one. That is the reason why i proposed the idea here