Hey! Since I’m already working with unity on linux as a productive environment, I thought I’d share what makes the possibility to work under linux so good - Being able to use vim and a terminal emulator to work on your sources.
Why Vim?
Vim is fast an lightweight. Vim inside your favorite shell let’s you keep your hands on the keyboard and automate things with aliases and scripts. Vim can look great and no UI elements blocking you from viewing your code.
Should I use it too?
Only if you’re comfortable with vim keybindings and already heard of vim plugins. Visit
For your pleasure.
You can always still use MonoDevelop with Unity, it’ll run in the background independent of Unity or MD.
How does it look and feel on linux?
Good question! That’s the most important part. It looks glorious on linux. I’m currently using xfce4 and a customized terminator and I love it.
How can I have it?
-
Installing vim is easy, just get it with your favorite package manager.
-
Using plugins in vim is also easy, but there are several ways. I personally prefer pathogen. Please take a look at GitHub - tpope/vim-pathogen: pathogen.vim: manage your runtimepath
-
These are the plugins I use:
auto-pairs/
omnisharp-vim/
rainbow_parentheses.vim/
syntastic/
tagbar/
vim-airline/
vim-colorschemes/
vim-colors-solarized/
vim-dispatch/
vim-easymotion/
vim-multiple-cursors/
YouCompleteMe/
- For Unity AutoCompletion you’ll especially depend on omnisharp-vim, Syntastic and YouCompleteMe. Again, there are alternatives, but this is what I use.
There is a detailed documentation for omnisharp-vim which you’ll have to follow to install it. It’s something like that:
cd ~/.vim/bundle
git clone GitHub - OmniSharp/omnisharp-vim: Vim omnicompletion (intellisense) and more for C#
cd omnisharp-vim
git submodule update --init --recursive
cd server
xbuild
Which can possibly fail on xbuild. It depends on the mono project, which you can easily install via apt-get or dnf, but(!) can still fail if installed. The crucial part is that you’ll have like the new-new version of mono to compile it. Something like 3.2.4 or so should do the trick.
Also don’t forget to compile YouCompleteMe:
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer
If installed and compiled correctly, you can update your .vimrc to include omnisharp, syntastic and YouCompleteMe.
Here is my complete vimrc file: https://www.fumiko-game.com/cloud/index.php/s/REB6weWElTZUrU0/download
And (I guess) only the autocompletion stuff: https://www.fumiko-game.com/cloud/index.php/s/yD6wHIGbBrv3GEr/download
I’m not sure about everything in my .vimrc, so don’t expect a perfect example - It’s just what works for me and doesn’t let me down.
How do I know that it works?
Open a source .cs file in your project and see if vim asks you to open one of the solution files:
Just choose one (I experienced no difference, don’t know if there should be two or just one .sln) and if you’ve got AutoCompletion on objects and variables you’re good to go, that’s all we wanted - Proper auto completion for vim that includes Unity’s predefined classes.
ps aux | grep omnisharp
should show something like:
That shows us that the OmniSharp Server is running in the background.
Now just edit your files, mess with your code, save with :w and switch to Unity to auto-compile your efforts. Syntastic will tell you about any typos and bad practice and Unity will tell you if something has gone wrong.
I hope this helps some people setting up Unity with vim since I’ve always wanted to do it but I didn’t even want to try it under windows since the implementation of vim is so clunky.
I don’t know if I forgot anything important for the installation since I set it all up two weeks ago. Feel free to ask if there are any issues, maybe I can help.