Inside Out

Notes on seeking wisdom and crafting software

OmniSharp on linux

Table of contents

Few notes on my setup of OmniSharp with vim. OmniSharp provides a cross platform language service for .NET on any editor.


Use your favorite vim plugin manager (e.g. pathogen) and add this bundle.

$ git clone bundle/omnisharp-vim

The vim plugin may use the core OmniSharp-roslyn functionality for code completion etc. On archlinux, OmniSharp-roslyn is available on AUR.

$ yaourt -S omnisharp-roslyn

These bits are installed to /opt/omnisharp-roslyn.


You can find my complete vim configuration here. It is based off the defaults with few tweaks. Few key ones are below:

  1. Enable the roslyn based server
let g:OmniSharp_server_type = 'roslyn'
  1. Invocation On windows box, I compile omnisharp-roslyn on my own, hence the activation script is within the bundle directory. On linux, we are using the binary release with a helper omnisharp-script.
if GetPlatform() == "win"
    let g:OmniSharp_server_path = join([expand('~'), 'vimfiles', 'bundle', 'omnisharp-vim', 'omnisharp-roslyn', 'artifacts', 'scripts', 'Omnisharp'], '/')
    let g:OmniSharp_server_path = join([expand('~'), 'bin', 'OmniSharp'], '/')
  1. Setting up omnisharp code actions
" Enable code actions via ctrlp
let g:OmniSharp_selector_ui = 'ctrlp'

It’s a nice little integration with ctrlp plugin.

Quick usage

Here’s some of my frequently used shortcuts.

  • Use Ctrl+X Ctrl+O in insert mode to trigger auto complete
  • <Leader>space trigger code actions like remove unused namespaces
  • Move to a Type or Variable under cursor and try
    • <Leader>fu finds usages of the symbol under cursor
    • <Leader>fs finds the symbol
  • and can navigate down/up to next symbol in current buffer

Aside: looking back, last time I seriously tried using VIM for .net was back in 2009ish. Here’s what we had then, and with OmniSharp we’ve come a long way!

Enjoy OmniSharp. Namaste!