From 16fd0ed4992e83101ba96be8f266c56922afa6f7 Mon Sep 17 00:00:00 2001 From: ec965 <22567131+ec965@users.noreply.github.com> Date: Thu, 6 Oct 2022 22:48:35 -0700 Subject: [PATCH] Fix ordering of wsl and win --- lua/openingh/utils.lua | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lua/openingh/utils.lua b/lua/openingh/utils.lua index 6b3317f..82b7f7f 100644 --- a/lua/openingh/utils.lua +++ b/lua/openingh/utils.lua @@ -80,20 +80,30 @@ end -- opens a url in the correct OS function M.open_url(url) - if vim.fn.has("mac") then + -- order here matters + -- wsl must come before win + -- wsl must come before linux + + if vim.fn.has("mac") == 1 then vim.fn.system("open " .. url) return true - elseif vim.fn.has("win64") or vim.fn.has("win32") then - vim.fn.system("start " .. url) - return true - elseif vim.fn.has("wsl") then + end + + if vim.fn.has("wsl") == 1 then vim.fn.system("explorer.exe " .. url) return true - elseif vim.fn.has("linux") then + end + + if vim.fn.has("win64") == 1 or vim.fn.has("win32") == 1 then + vim.fn.system("start " .. url) + return true + end + + if vim.fn.has("linux") == 1 then vim.fn.system("xdg-open " .. url) return true end - + return false end