omnisharp-emacs is a port of the awesome omnisharp-roslyn server to the Emacs text editor. It provides IDE-like features for editing files in C# solutions in Emacs, provided by an OmniSharp server instance that works in the background.
This package is licensed under GNU General Public License version 3, or (at your option) any later version.
This package requires Emacs 24.3 and above. It has been tested on Ubuntu, Windows 7+ and on macOS.
Installation on Spacemacs
csharp layer to
will get installed automatically for you on restart.
Installation on Regular Emacs
To install, use MELPA. After MELPA is configured correctly, use
M-x package-refresh-contents RET M-x package-install omnisharp RET
When installing the
package.el will also
automatically pull in
csharp-mode for you as well.
To automatically load omnisharp-emacs when editing csharp files, add
something like this to
csharp-mode-hook on your
(add-hook 'csharp-mode-hook 'omnisharp-mode)
For autocompletion via company mode you will also need this in your
(eval-after-load 'company '(add-to-list 'company-backends 'company-omnisharp))
To start using omnisharp-emacs, start the server with
M-x omnisharp-start-omnisharp-server RET. The command will prompt you for
a project or solution file you want to work with.
You will probably want to create a custom configuration for omnisharp-emacs
in your normal coding sessions. Usually all this customization
goes in your custom
Here is a sample configuration script (that goes into your
or in your
(defun my-csharp-mode-setup () (setq indent-tabs-mode nil) (setq c-syntactic-indentation t) (c-set-style "ellemtel") (setq c-basic-offset 4) (setq truncate-lines t) (setq tab-width 4) (setq evil-shift-width 4) (local-set-key (kbd "C-c C-c") 'recompile)) (add-hook 'csharp-mode-hook 'my-csharp-mode-setup t)
There is also an example configuration for evil-mode included in the project,
This emacs package requires the omnisharp-roslyn server program. Emacs will manage connection to the server as a subprocess.
The easiest/default way to install the server is to invoke
M-x omnisharp-install-server and follow instructions on minibufer.
If that fails (or you feel adventurous) please see installing omnisharp server on how to install the server manually.
How to run tests
You can run all kind of tests by following shell script.
Pull requests welcome!