This is a helper package that automatically installs and updates OmniSharp for you.
To use this package, you must have:
- The LSP package.
- The .NET SDK. (The "Core" version does not work on macOS.)
- (Optional but recommended) Install the LSP-file-watcher-chokidar via Package Control to enable functionality to notify the server about new files.
This language server operates on views with the source.cs
base scope.
The plugin is available on github. To install, clone the repo in sublime the Packages
directory.
The server is installed in the $DATA/Package Storage/LSP-OmniSharp directory, where $DATA is the base data path of Sublime Text.
For instance, $DATA is ~/.config/sublime-text
on a Linux system. If you want to force a re-installation of the server,
you can delete the entire $DATA/Package Storage/LSP-OmniSharp directory.
Like any helper package, installation starts when you open a view that is suitable for this language server. In this
case, that means that when you open a view with the source.cs
base scope, installation commences.
Configure OmniSharp by running Preferences: LSP-OmniSharp Settings
from the Command Palette.
Alternatively, choose "Settings -> Package Settings -> LSP -> Servers -> LSP OmniSharp"
OmniSharp can do a lot of cool things, like
- code completion
- signature help
- hover info
- some quality code actions
- formatting
- find references
- goto def
The following steps will enable OmniSharp on Unity for Mac OS.
-
Install the "Visual Studio" devtool from within Unity. This can be done from the Unity Hub when installing a new Unity editor or by choosing "Add modules" to an existing editor installation.
-
Set Visual Studio as the external editor for Unit:
Settings -> External Tools -> External Script Editor
-
Generate visual studio solution files within a Unity project:
Settings -> External Tools -> Regenerate project files
NOTE: This currently needs to be done every time a new .cs file is added to a Unity project
-
Create a sublime project for the Unity project from Sublime:
Project -> Save Project As...
-
Add the following setting to your .sublime-project file created in step #4
"settings": { "LSP-OmniSharp.omnisharp_source" : "$projectdir" }
-
Use the system installed version of mono instead of the one provided by the plugin.
From
Settings -> Package Settings -> LSP -> Servers -> LSP OmniSharp
Add:
"mono_binary" : "mono",
or
"mono_binary" : "/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono",
-
Relaunch Sublime Check the console to ensure that the
LSP-OmniSharp: Server Command
has the correct path tomono
and includes a'--source
argument corresponding to the Unity project directory.
At this point Sublime should recognize the built in Unity classes.
Shortcomings:
-
When adding a new script in the Unity project you must redo step #3 above, i.e. run "Settings -> External Tools -> Regenerate project files". This will update the .csproj necessary. Then you'll need to restart the server by executing the "LSP: Restart Server" command.
-
The methods for UnityEngine.MonoBehavior don't show up as autocomplete options. It looks like this is because they are not actually overridden methods (since there's no
override
keyword) so OmniSharp doesn't recognize messages as valid completions. -
The default editor for the Unity project is still Visual Studio since project files need to be generated. Sublime must be launched independently.