diff --git a/runtime/lua/provider/python/health.lua b/runtime/lua/provider/python/health.lua index f2f6c9ef01..d0f420bf7f 100644 --- a/runtime/lua/provider/python/health.lua +++ b/runtime/lua/provider/python/health.lua @@ -1,5 +1,5 @@ local health = vim.health -local iswin = vim.uv.os_uname().sysname == 'Windows_NT' +local iswin = vim.fn.has('win32') == 1 local M = {} diff --git a/runtime/lua/vim/fs.lua b/runtime/lua/vim/fs.lua index b05220ee2c..a0d3813c2f 100644 --- a/runtime/lua/vim/fs.lua +++ b/runtime/lua/vim/fs.lua @@ -1,6 +1,8 @@ local M = {} -local iswin = vim.uv.os_uname().sysname == 'Windows_NT' +-- Can't use `has('win32')` because the `nvim -ll` test runner doesn't support `vim.fn` yet. +local sysname = vim.uv.os_uname().sysname:lower() +local iswin = not not (sysname:find('windows') or sysname:find('mingw')) local os_sep = iswin and '\\' or '/' --- Iterate over all the parents of the given path. diff --git a/runtime/lua/vim/loader.lua b/runtime/lua/vim/loader.lua index ea77a22416..2fbc9c5e57 100644 --- a/runtime/lua/vim/loader.lua +++ b/runtime/lua/vim/loader.lua @@ -208,8 +208,7 @@ end ---@return string|function ---@private function Loader.loader_lib(modname) - local sysname = uv.os_uname().sysname:lower() or '' - local is_win = sysname:find('win', 1, true) and not sysname:find('darwin', 1, true) + local is_win = vim.fn.has('win32') == 1 local ret = M.find(modname, { patterns = is_win and { '.dll' } or { '.so' } })[1] if ret then -- Making function name in Lua 5.1 (see src/loadlib.c:mkfuncname) is diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua index 3c63a12da2..22485f77ab 100644 --- a/runtime/lua/vim/lsp/rpc.lua +++ b/runtime/lua/vim/lsp/rpc.lua @@ -3,7 +3,7 @@ local log = require('vim.lsp.log') local protocol = require('vim.lsp.protocol') local validate, schedule, schedule_wrap = vim.validate, vim.schedule, vim.schedule_wrap -local is_win = uv.os_uname().version:find('Windows') +local is_win = vim.fn.has('win32') == 1 --- Checks whether a given path exists and is a directory. ---@param filename string path to check diff --git a/test/testutil.lua b/test/testutil.lua index 439f13cf49..ff05a9ce20 100644 --- a/test/testutil.lua +++ b/test/testutil.lua @@ -369,7 +369,7 @@ function M.check_logs() ) end -function M.sysname() +local function sysname() return uv.os_uname().sysname:lower() end @@ -380,11 +380,11 @@ function M.is_os(s) error('unknown platform: ' .. tostring(s)) end return not not ( - (s == 'win' and (M.sysname():find('windows') or M.sysname():find('mingw'))) - or (s == 'mac' and M.sysname() == 'darwin') - or (s == 'freebsd' and M.sysname() == 'freebsd') - or (s == 'openbsd' and M.sysname() == 'openbsd') - or (s == 'bsd' and M.sysname():find('bsd')) + (s == 'win' and (sysname():find('windows') or sysname():find('mingw'))) + or (s == 'mac' and sysname() == 'darwin') + or (s == 'freebsd' and sysname() == 'freebsd') + or (s == 'openbsd' and sysname() == 'openbsd') + or (s == 'bsd' and sysname():find('bsd')) ) end