OmniSharp-VIM, OmniSharp-Roslyn, and dotnet core on Ubuntu 16.10 - Syntax checking not recognizing C# 6 and requires solution file
Asked Answered
T

1

7

I am trying to set up my Ubuntu machine for dotnet core development. I've painstakingly installed Omnisharp-vim and set it to work with the OmniSharp-Roslyn server. I also have Syntastic and YouCompleteMe installed. I am getting syntax checking and Intellisense. I have two problems though:

  1. Omnisharp-vim does not work without a solution file. Dotnet core projects don't have to have solutions files. How do I get around this?

  2. I am getting syntax error for valid C# 6 code. For instance, it does not recognize the nameof operator.

Thigmotropism answered 4/11, 2016 at 21:6 Comment(0)
T
5

How?

Add a valid global.json file to your root directory.

{}

Add two lines to the top of your vimrc file.

let g:OmniSharp_server_type = 'roslyn'
let g:OmniSharp_prefer_global_sln = 1

Why?

Those two OmniSharp settings tell omnisharp-vim to use Roslyn and to use the directory that contains a global.json file.

Here is the OmniSharp.vim file source-code that uses those variables.

if g:OmniSharp_server_type ==# 'roslyn' && g:OmniSharp_prefer_global_sln
  let global_solution_files = s:globpath(dir, 'global.json')
  call filter(global_solution_files, 'filereadable(v:val)')
  if !empty(global_solution_files)
    let solution_files = [dir]
    break
  endif
endif

If that does not work...

Try starting OmniSharp manually from the command line:

omnisharp-vim\omnisharp-roslyn\artifacts\scripts\OmniSharp.cmd -s C:\temp\

The C:\temp\ directory contains a new .NET Core project with a valid global.json file.

Travistravus answered 20/2, 2017 at 0:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.