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.

1 Answer 1

4

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.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.