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:
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?
I am getting syntax error for valid C# 6 code. For instance, it does not recognize the nameof operator.
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
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With