Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411283 Posts in 69325 Topics- by 58380 Members - Latest Member: bob1029

March 29, 2024, 07:14:44 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Unity3d on Linux + Vim
Pages: [1]
Print
Author Topic: Unity3d on Linux + Vim  (Read 2163 times)
odrez
Level 0
**


Hey!


View Profile WWW
« on: October 05, 2015, 11:44:17 AM »

Hey! Since I'm new and I've made this tutorial lately, I thought it would be a good Idea to start sharing it with you guys.

I'm already working with the experimental unity3d linux build as a productive environment, and this is why I think it's so good - Being able to use vim and a terminal emulator to work on your sources.

Find the latest build for unity3d linux here: link

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

http://www.openvim.com/
http://vim-adventures.com/
http://vimawesome.com/

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. You can display contents of files quickly and start scripts, move stuff, copy stuff etc., all without leaving your keyboard.





How can I have it?

1. Installing vim is easy, just get it with your favorite package manager.

2. Using plugins in vim is also easy, but there are several ways. I personally prefer pathogen. Please take a look at https://github.com/tpope/vim-pathogen

3. 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/

4. For Unity AutoCompletion you'll especially depend on omnisharp-vim, Syntastic and YouCompleteMe. Again, there are alternatives, but this is what I use.

http://vimawesome.com/plugin/youcompleteme
http://vimawesome.com/plugin/syntastic
https://github.com/OmniSharp/omnisharp-vim

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 https://github.com/OmniSharp/omnisharp-vim.git
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: http://www.fumiko-game.com/fumiko/wp-content/uploads/.vimrc
And (I guess) only the autocompletion stuff: http://www.fumiko-game.com/fumiko/wp-content/uploads/.vimrc_onlycompletion

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:
Code:
"ManagesAbilities.cs" [noeol] 38L, 795C
sln:
1 - /home/user/Documents/dev/unity3d/fumiko/fumiko-csharp.sln
2 - /home/user/Documents/dev/unity3d/fumiko/fumiko.sln
Choose a solution file and press enter

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.

Code:
ps aux | grep omnisharp

should show something like:

Code:
user      7909  0.0  0.0  13908  3028 pts/4    S+   11:29   0:00 /bin/bash -c echo $$ > /tmp/vH4zBvf/1.pid; perl -e "select(undef,undef,undef,0.1)" 2>/dev/null; mono '/home/user/.vim/bundle/omnisharp-vim/server/OmniSharp/bin/Debug/OmniSharp.exe' -p 2000 -s '/home/user/Documents/dev/unity3d/fumiko/fumiko.sln'; test $? = 0 -o $? = 130 || (printf '?[1m--- Press ENTER to continue ---?[0m\n' $?; exec head -1); rm -f /tmp/vH4zBvf/1.pid
user      7918 19.1  1.5 498260 127532 pts/4   Sl+  11:29   0:03 mono /home/user/.vim/bundle/omnisharp-vim/server/OmniSharp/bin/Debug/OmniSharp.exe -p 2000 -s /home/user/Documents/dev/unity3d/fumiko/fumiko.sln
user      7974  0.0  0.0  13216  2352 pts/9    S+   11:29   0:00 grep --colour=auto omnisharp

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 many weeks ago. Feel free to ask if there are any issues, maybe I can help.

(I just found the tutorial section after making this post.. oups. Maybe someone can move it. ^^)
« Last Edit: January 09, 2016, 01:46:41 AM by odrez » Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic