mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
backport: fix(vim.fs): dirname() returns "." on mingw/msys2 (#30484)
fix(vim.fs): dirname() returns "." on mingw/msys2 #30480
Problem:
`vim.fs.dirname([[C:\User\XXX\AppData\Local]])` returns "." on
mingw/msys2.
Solution:
- Check for "mingw" when deciding `iswin`.
- Use `has("win32")` where possible, it works in "fast" contexts since
b02eeb6a72
.
This commit is contained in:
parent
2a8d80a442
commit
6a44055a71
@ -1,5 +1,5 @@
|
|||||||
local health = vim.health
|
local health = vim.health
|
||||||
local iswin = vim.uv.os_uname().sysname == 'Windows_NT'
|
local iswin = vim.fn.has('win32') == 1
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
local M = {}
|
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 '/'
|
local os_sep = iswin and '\\' or '/'
|
||||||
|
|
||||||
--- Iterate over all the parents of the given path.
|
--- Iterate over all the parents of the given path.
|
||||||
|
@ -208,8 +208,7 @@ end
|
|||||||
---@return string|function
|
---@return string|function
|
||||||
---@private
|
---@private
|
||||||
function Loader.loader_lib(modname)
|
function Loader.loader_lib(modname)
|
||||||
local sysname = uv.os_uname().sysname:lower() or ''
|
local is_win = vim.fn.has('win32') == 1
|
||||||
local is_win = sysname:find('win', 1, true) and not sysname:find('darwin', 1, true)
|
|
||||||
local ret = M.find(modname, { patterns = is_win and { '.dll' } or { '.so' } })[1]
|
local ret = M.find(modname, { patterns = is_win and { '.dll' } or { '.so' } })[1]
|
||||||
if ret then
|
if ret then
|
||||||
-- Making function name in Lua 5.1 (see src/loadlib.c:mkfuncname) is
|
-- Making function name in Lua 5.1 (see src/loadlib.c:mkfuncname) is
|
||||||
|
@ -3,7 +3,7 @@ local log = require('vim.lsp.log')
|
|||||||
local protocol = require('vim.lsp.protocol')
|
local protocol = require('vim.lsp.protocol')
|
||||||
local validate, schedule, schedule_wrap = vim.validate, vim.schedule, vim.schedule_wrap
|
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.
|
--- Checks whether a given path exists and is a directory.
|
||||||
---@param filename string path to check
|
---@param filename string path to check
|
||||||
|
@ -369,7 +369,7 @@ function M.check_logs()
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.sysname()
|
local function sysname()
|
||||||
return uv.os_uname().sysname:lower()
|
return uv.os_uname().sysname:lower()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -380,11 +380,11 @@ function M.is_os(s)
|
|||||||
error('unknown platform: ' .. tostring(s))
|
error('unknown platform: ' .. tostring(s))
|
||||||
end
|
end
|
||||||
return not not (
|
return not not (
|
||||||
(s == 'win' and (M.sysname():find('windows') or M.sysname():find('mingw')))
|
(s == 'win' and (sysname():find('windows') or sysname():find('mingw')))
|
||||||
or (s == 'mac' and M.sysname() == 'darwin')
|
or (s == 'mac' and sysname() == 'darwin')
|
||||||
or (s == 'freebsd' and M.sysname() == 'freebsd')
|
or (s == 'freebsd' and sysname() == 'freebsd')
|
||||||
or (s == 'openbsd' and M.sysname() == 'openbsd')
|
or (s == 'openbsd' and sysname() == 'openbsd')
|
||||||
or (s == 'bsd' and M.sysname():find('bsd'))
|
or (s == 'bsd' and sysname():find('bsd'))
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user