How to setup Omnisharp on Linux for Unity C# with Mono via `nvim-lspconfig`?

I’ve spent days trying to setup neovim’s LSP for Unity development in C# with Mono and I’m at a loss…

Other LSP servers related to bash, lua, etc all work as expected.

While I don’t think it should matter, it may be worth noting my current setup. I have Unity installed on my system’s Windows installation and I’m running Linux through a virtual machine. Unity related projects are then “shared” to the VM. So the Linux environment is “Unity free”, I’m just using it for the vim/neovim coding side of things. The VM is where I’ve done all of my non-Unity dev stuff so that’s why I’m trying to carry that forward into Unity related work if possible.

Currently on Ubuntu 20.04.4 LTS x86_64

$ nvim --version

NVIM v0.8.0-dev+593-g5e5374035
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by root@linux-VirtualBox

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info

Here is what I have tried so far


local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
if not status_ok then

local lspconfig = require("lspconfig")

local servers = {

	ensure_installed = servers,

for _, server in pairs(servers) do
	local opts = {
		on_attach = require("user.lsp.handlers").on_attach,
		capabilities = require("user.lsp.handlers").capabilities,
	local has_custom_opts, server_custom_opts = pcall(require, "user.lsp.settings." .. server)
	if has_custom_opts then
		opts = vim.tbl_deep_extend("force", opts, server_custom_opts)


local M = {}

... -- Various keymaps and other customizations, trying to isolate just the relevant portions

M.on_attach = function(client, bufnr)
	-- vim.notify( .. " starting...")
	-- TODO: refactor this into a method that checks if string in list
	if == "tsserver" then
		client.resolved_capabilities.document_formatting = false

local capabilities = vim.lsp.protocol.make_client_capabilities()

local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not status_ok then

M.capabilities = cmp_nvim_lsp.update_capabilities(capabilities)

return M


-- Mono
local omnisharp_bin = "mono /home/linux/.local/share/nvim/lsp_servers/omnisharp/omnisharp-mono/OmniSharp.exe"

-- Roslyn
  -- local omnisharp_bin = "/home/linux/.local/omnisharp_roslyn/run"

local pid = vim.fn.getpid()
local util = require 'lspconfig/util'

return {
    use_mono = true,

    cmd = { omnisharp_bin, "--languageserver" , "--hostPID", tostring(pid) };

(neovim) :LspInfo

1 client(s) attached to this buffer: 
 Client: omnisharp (id: 5, pid: 14634, bufnr: [46])
 	filetypes:       cs, vb
 	autostart:       true
 	root directory:  /home/linux/<redacated>
 	cmd:             mono /home/linux/.local/share/nvim/lsp_servers/omnisharp/omnisharp-mono/OmniSharp.exe --languageserver --hostPID 14505


mono-project was installed with the following script, confirmed with --version and in being able to compile and execute the example code:

sudo apt-get install git autoconf libtool automake build-essential gettext cmake python3 curl -y

sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp:// --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update && \
sudo apt install mono-complete -y

$ mono --version

Mono JIT compiler version (tarball Tue Jun 14 22:35:00 UTC 2022)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors.
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	Interpreter:   yes
	LLVM:          yes(610)
	Suspend:       hybrid
	GC:            sgen (concurrent by default)

The various lsp related plugins I am currently using are

-- LSP and related {{{

-- completion {{{


UPDATE 20220726 20:14

Something I noticed when running :LspLog

OmniSharp.CompositionHostBuilder: It looks like you have Mono installed which contains a MSBuild lower than 17.0.0 which is the minimum supported by the configured .NET Core Sdk.\n Try updating Mono to the latest stable or preview version to enable better .NET Core Sdk support.

Will start digging into the Mono install and with how the associated mono server is being called by Neovim’s LSP stuff…

UPDATE 20220726 20:43

$ dotnet msbuild -ver
Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

Seems the Neovim LSP server is using something different from what is output here… Hmm…

Did you figure this out?

For Windows

I figured it out! Here’s what I did:

start "" pwsh /c "nvr --servername unity --remote-silent %*"
  • installed Visual Studio 2022 and selected “Game development with Unity”.
  • I installed csharp_ls (for language server protocol support) and csharpier (for code formatting).
  • In Unity, I went to Edit > External Tools and selected the neovim-unity.bat script as the external script editor.

By following these steps, I was able to integrate Neovim with Unity.

For Linux

Configure (Neo)Vim for Unity Game Engine Development (