From 2507c1e2f053068c5edee00472fd5279cb803393 Mon Sep 17 00:00:00 2001 From: ec965 <22567131+ec965@users.noreply.github.com> Date: Thu, 6 Oct 2022 22:15:21 -0700 Subject: [PATCH 1/3] Add wsl support --- lua/openingh/utils.lua | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lua/openingh/utils.lua b/lua/openingh/utils.lua index 38191ad..7d68235 100644 --- a/lua/openingh/utils.lua +++ b/lua/openingh/utils.lua @@ -80,22 +80,19 @@ end -- opens a url in the correct OS function M.open_url(url) - local os = vim.loop.os_uname().sysname - if os == "Darwin" then + if vim.fn.has("mac") then io.popen("open " .. url) return true - end - - if os == "Windows" then + elseif vim.fn.has("win64") or vim.fn.has("win32") then io.popen("start " .. url) return true - end - - if os == "Linux" then + elseif vim.fn.has("wsl") then + io.popen("explorer.exe " .. url) + elseif vim.fn.has("linux") then io.popen("xdg-open " .. url) return true end - + return false end From 868fdb39e95c0ea0ec2aeacb5da622a99a8dddac Mon Sep 17 00:00:00 2001 From: ec965 <22567131+ec965@users.noreply.github.com> Date: Thu, 6 Oct 2022 22:27:53 -0700 Subject: [PATCH 2/3] Return true for wsl --- lua/openingh/utils.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/openingh/utils.lua b/lua/openingh/utils.lua index 7d68235..6b3317f 100644 --- a/lua/openingh/utils.lua +++ b/lua/openingh/utils.lua @@ -81,15 +81,16 @@ end -- opens a url in the correct OS function M.open_url(url) if vim.fn.has("mac") then - io.popen("open " .. url) + vim.fn.system("open " .. url) return true elseif vim.fn.has("win64") or vim.fn.has("win32") then - io.popen("start " .. url) + vim.fn.system("start " .. url) return true elseif vim.fn.has("wsl") then - io.popen("explorer.exe " .. url) + vim.fn.system("explorer.exe " .. url) + return true elseif vim.fn.has("linux") then - io.popen("xdg-open " .. url) + vim.fn.system("xdg-open " .. url) return true end 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 3/3] 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