OmniSharp on linux
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 https://github.com/OmniSharp/OmniSharp-vim.git 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
You can find my complete vim configuration here. It is based off the defaults with few tweaks. Few key ones are below:
- Enable the roslyn based server
let g:OmniSharp_server_type = 'roslyn'
On windows box, I compile
omnisharp-roslynon 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'], '/') else let g:OmniSharp_server_path = join([expand('~'), 'bin', 'OmniSharp'], '/') endif
- 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.
Here’s some of my frequently used shortcuts.
Ctrl+X Ctrl+Oin insert mode to trigger auto complete
<Leader>spacetrigger code actions like remove unused namespaces
Move to a Type or Variable under cursor and try
<Leader>fufinds usages of the symbol under cursor
<Leader>fsfinds 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!