Compile omnisharp-roslyn server

Clone omnisharp-roslyn

Use command ./ to compile omnisharp-roslyn server (omnisharp-roslyn will be compiled with local environment mono)

.vimrc settings

Add Plug 'prabirshrestha/asyncomplete.vim' and Plug 'OmniSharp/omnisharp-vim' in .vimrc and do :PlugInstall

Copy the following script to .vimrc

Don’t forget to change the value of let g:OmniSharp_server_path = '' to the absolute path of OmniSharp.exe which built just now.

" OmniSharp
"" Compile omnisharp-roslyn locally and set the artifacts OmniSharp.exe to OmniSharp_server_path
let g:OmniSharp_server_path = '/Users/{username}/{directory}/omnisharp-roslyn/artifacts/publish/OmniSharp.Stdio.Driver/mono/OmniSharp.exe'

"" The roslyn server releases come with an embedded Mono, but this can be overridden to use the installed Mono by setting g:OmniSharp_server_use_mono
let g:OmniSharp_server_use_mono = 1

"" Timeout in seconds to wait for a response from the server
let g:OmniSharp_timeout = 1

"" Get Code Issues and syntax errors
let g:syntastic_cs_checkers = ['syntax', 'semantic', 'issues']

augroup omnisharp_commands

    "" Set autocomplete function to OmniSharp (if not using YouCompleteMe completion plugin)
    autocmd FileType cs setlocal omnifunc=OmniSharp#Complete

    "" automatic syntax check on events (TextChanged requires Vim 7.4)
    autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck

    "" The following commands are contextual, based on the current cursor position.
    autocmd FileType cs nnoremap gd :OmniSharpGotoDefinition<cr>
    autocmd FileType cs nnoremap <space>fi :OmniSharpFindImplementations<cr>
    autocmd FileType cs nnoremap <space>ft :OmniSharpFindType<cr>
    autocmd FileType cs nnoremap <space>fs :OmniSharpFindSymbol<cr>
    autocmd FileType cs nnoremap <space>fu :OmniSharpFindUsages<cr>
    "" finds members in the current buffer
    autocmd FileType cs nnoremap <space>fm :OmniSharpFindMembers<cr>
    "" cursor can be anywhere on the line containing an issue
    autocmd FileType cs nnoremap <space>fx :OmniSharpFixUsings<cr>
    autocmd FileType cs nnoremap <space>tt :OmniSharpTypeLookup<cr>
    autocmd FileType cs nnoremap <space>dc :OmniSharpDocumentation<cr>
    "" navigate up by method/property/field
    autocmd FileType cs nnoremap <C-K> :OmniSharpNavigateUp<cr>
    "" navigate down by method/property/field
    autocmd FileType cs nnoremap <C-J> :OmniSharpNavigateDown<cr>
    "" Contextual code actions (requires CtrlP or unite.vim)
    autocmd FileType cs nnoremap <space>a :OmniSharpGetCodeActions<cr>
    "" Run code actions with text selected in visual mode to extract method
    autocmd FileType cs vnoremap <space>a :call OmniSharp#GetCodeActions('visual')<cr>
    "" rename with dialog
    autocmd FileType cs nnoremap <space>rm :OmniSharpRename<cr>
    "" Force OmniSharp to reload the solution. Useful when switching branches etc.
    autocmd FileType cs nnoremap <space>cf :OmniSharpCodeFormat<cr>
    "" (Experimental - uses vim-dispatch or vimproc plugin) - Restart the omnisharp server for the current solution
    autocmd FileType cs nnoremap <space>rs :OmniSharpRestartServer<cr>
    "" Add syntax highlighting for types and interfaces
    autocmd FileType cs nnoremap <space>th :OmniSharpHighlightTypes<cr>
augroup END

If you have ale plugin installed, make sure to set ale_linters with OmniSharp, otherwise you’ll got many lint errors.

"" only enable these linters
 let g:ale_linters = {
 \    'javascript': ['eslint'],
 \    'cs': ['OmniSharp']

Unity3D development in MacVim

  • Right click *.cs file from the Finder, select “Open With” -> “MacVim” as the default Editor in your system.

  • Set Unity3D Preferences -> External Tools -> External Script Editor to “Open by file extension”.

  • Create/Delete/Rename/Move C# script files from Unity3D Editor (Which will handle the .meta files).

  • Double click C# script in Unity3D project view to open MacVim for development.

If you don’t want to set MacVim as system default editor. You can also set as Unity3D default editor. But if you double-click scripts in Unity3D project view multiple times, Unity3D will create multiple MacVim applications (You’ll see them while pressing Command + Tab).

That’s what we don’t want to see. We only want to have one MacVim application when press Command + Tab and can switch workspaces with Command + ~. The following steps can help.

  • Create a bash script which start MacVim. Its content can simply be mvim $@

  • Download appify script.

  • Type the following commands:

chmod a+x appify
chmod a+x
./applify "open_macvim"
  • Then you’ll get an

  • Select from Unity3D as default editor.




Unity3D and .NET Framework

Unity3D Command line arguments

Issue: Doesn’t download OmniSharp-Roslyn before trying to start on macOS


Unity opens multiple workspaces when using VSCode as editor