diff options
| author | Sassan Haradji <sassanh@gmail.com> | 2022-05-17 16:36:32 +0430 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-17 14:06:32 +0200 |
| commit | 9cf6e2d068ca0d3261ee163c523c14a432ee09d1 (patch) | |
| tree | b5670412eff2112ed20dee0de78553a11a4dfb7b /lua | |
| parent | chore(functional): restructure and extend functional modules (#703) (diff) | |
| download | mason-9cf6e2d068ca0d3261ee163c523c14a432ee09d1.tar mason-9cf6e2d068ca0d3261ee163c523c14a432ee09d1.tar.gz mason-9cf6e2d068ca0d3261ee163c523c14a432ee09d1.tar.bz2 mason-9cf6e2d068ca0d3261ee163c523c14a432ee09d1.tar.lz mason-9cf6e2d068ca0d3261ee163c523c14a432ee09d1.tar.xz mason-9cf6e2d068ca0d3261ee163c523c14a432ee09d1.tar.zst mason-9cf6e2d068ca0d3261ee163c523c14a432ee09d1.zip | |
add mono version of omnisharp (#688)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-lsp-installer/servers/omnisharp/init.lua | 73 |
1 files changed, 42 insertions, 31 deletions
diff --git a/lua/nvim-lsp-installer/servers/omnisharp/init.lua b/lua/nvim-lsp-installer/servers/omnisharp/init.lua index ba15f1d4..d570e57e 100644 --- a/lua/nvim-lsp-installer/servers/omnisharp/init.lua +++ b/lua/nvim-lsp-installer/servers/omnisharp/init.lua @@ -4,9 +4,30 @@ local path = require "nvim-lsp-installer.core.path" local functional = require "nvim-lsp-installer.core.functional" local github = require "nvim-lsp-installer.core.managers.github" local std = require "nvim-lsp-installer.core.managers.std" +local Result = require "nvim-lsp-installer.core.result" local coalesce, when = functional.coalesce, functional.when +local generate_cmd = function(root_dir) + if vim.fn.executable "mono" then + return { + "mono", + path.concat { root_dir, "omnisharp-mono", "OmniSharp.exe" }, + "--languageserver", + "--hostPID", + tostring(vim.fn.getpid()), + } + else + return { + "dotnet", + path.concat { root_dir, "omnisharp", "OmniSharp.dll" }, + "--languageserver", + "--hostPID", + tostring(vim.fn.getpid()), + } + end +end + return function(name, root_dir) return server.Server:new { name = name, @@ -15,47 +36,37 @@ return function(name, root_dir) languages = { "c#" }, ---@param ctx InstallContext installer = function(ctx) - std.ensure_executable("dotnet", { help_url = "https://dotnet.microsoft.com/download" }) + Result.run_catching(function() + std.ensure_executable("mono", { help_url = "https://www.mono-project.com/download/stable/" }) + end):recover(function() + std.ensure_executable("dotnet", { help_url = "https://dotnet.microsoft.com/download" }) + end) - -- We write to the omnisharp directory for backwards compatibility reasons ctx.fs:mkdir "omnisharp" ctx:chdir("omnisharp", function() - github.unzip_release_file({ + github.unzip_release_file { repo = "OmniSharp/omnisharp-roslyn", asset_file = coalesce( - when( - platform.is_mac, - coalesce( - when(platform.arch == "x64", "omnisharp-osx-x64-net6.0.zip"), - when(platform.arch == "arm64", "omnisharp-osx-arm64-net6.0.zip") - ) - ), - when( - platform.is_linux, - coalesce( - when(platform.arch == "x64", "omnisharp-linux-x64-net6.0.zip"), - when(platform.arch == "arm64", "omnisharp-linux-arm64-net6.0.zip") - ) - ), - when( - platform.is_win, - coalesce( - when(platform.arch == "x64", "omnisharp-win-x64-net6.0.zip"), - when(platform.arch == "arm64", "omnisharp-win-arm64-net6.0.zip") - ) - ) + when(platform.is.mac_x64, "omnisharp-osx-x64-net6.0.zip"), + when(platform.is.mac_arm64, "omnisharp-osx-arm64-net6.0.zip"), + when(platform.is.linux_x64 == "x64", "omnisharp-linux-x64-net6.0.zip"), + when(platform.is.linux_arm64, "omnisharp-linux-arm64-net6.0.zip"), + when(platform.is.win_x64, "omnisharp-win-x64-net6.0.zip"), + when(platform.is.win_arm64, "omnisharp-win-arm64-net6.0.zip") ), + } + end) + + ctx.fs:mkdir "omnisharp-mono" + ctx:chdir("omnisharp-mono", function() + github.unzip_release_file({ + repo = "OmniSharp/omnisharp-roslyn", + asset_file = "omnisharp-mono.zip", }).with_receipt() end) end, default_options = { - cmd = { - "dotnet", - path.concat { root_dir, "omnisharp", "OmniSharp.dll" }, - "--languageserver", - "--hostPID", - tostring(vim.fn.getpid()), - }, + cmd = generate_cmd(root_dir), }, } end |
