Skip to content

Instantly share code, notes, and snippets.

@rafaeldelboni
Last active June 17, 2023 16:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaeldelboni/f09c35e9538ef8510bb5b56a50ce9d82 to your computer and use it in GitHub Desktop.
Save rafaeldelboni/f09c35e9538ef8510bb5b56a50ce9d82 to your computer and use it in GitHub Desktop.
How to setup Unity + Neovim LSP on Arch Linux

How to setup Unity + Neovim LSP on Arch Linux

Based on this post

Requirements

# Official repository
sudo pacman -S code dotnet-sdk mono mono-tools mono-msbuild mono-msbuild-sdkresolver mono-addins

# Aur repository
yay -Sy unityhub

...and yes you will need to install vscode, more on this later.

Omnisharp

Don't be tempted to install omnisharp from aur repositories. I mean, they work wonders for dotnet core applications, but not for Unity projects which are based on Mono, because of this I recommend installing it manually in your system.

Go to Omnisharp's release page and download the latest version of omnisharp-linux-x86.zip

unzip omnisharp-linux-x86.zip -d ~/.omnisharp
chmod +x /home/delboni/.omnisharp/run
sudo ln -sf /home/delboni/.omnisharp/ /usr/local/lib/omnisharp

Nvim

My setup is based on cajus-nvim so I did the following additions to the default files:

On line 61 add this function call (keep in mind the path you installed omnisharp will vary)

(lsp.omnisharp.setup {:on_attach on_attach
                      :handlers handlers
                      :capabilities capabilities
                      :cmd ["/usr/local/lib/omnisharp/run"]})

On line 6 add :c_sharp anywhere between the square brackets.

Unity

On Unity side you will need to install the vscode editor plugin.

Open Unity Editor -> Window -> Package Manager -> Search for Visual Studio Code Editor -> Install vscode-editor

Then you need to select your Script Editor as vscode and for this option be shown you need it installed (Note: Currently this is the only way the editor offers you the options to generate .csproj files)

Unity Editor -> Edit -> Preferences -> External Tools -> External Tools Editor -> Visual Studio Code Insiders
In the new area "Generate .csproj files for" thick all the check boxes and Click "Regenerate project files" button image

Using

Open your nvim from the root of any Unity project (usually where the .sln will be) and navigate to an script file.
Way a little bit to omnisharp parse your files and then do a :LspInfo something similar to the next printscreen should be shown LspInfo

Now you can use basic LSP commands like Documentation, Local Go To Definition and Auto Complete Working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment