aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2024-10-23 23:32:32 +0800
committercrupest <crupest@outlook.com>2024-10-26 16:49:08 +0800
commitd2f6bc3213a1464495789245bafbbbd3bc488bd5 (patch)
tree5183fbe2a8e5e01b6394b15af4bf2959ed940699
parentcbc08bcd0e60faf8452763594d22d4fc57cc5b80 (diff)
downloadcrupest-d2f6bc3213a1464495789245bafbbbd3bc488bd5.tar.gz
crupest-d2f6bc3213a1464495789245bafbbbd3bc488bd5.tar.bz2
crupest-d2f6bc3213a1464495789245bafbbbd3bc488bd5.zip
fix(nvim): fix full_path on Windows.
-rw-r--r--configs/nvim/config-root/lua/crupest/utils/fs.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/configs/nvim/config-root/lua/crupest/utils/fs.lua b/configs/nvim/config-root/lua/crupest/utils/fs.lua
index d34c2f6..f1363ff 100644
--- a/configs/nvim/config-root/lua/crupest/utils/fs.lua
+++ b/configs/nvim/config-root/lua/crupest/utils/fs.lua
@@ -1,3 +1,5 @@
+local is_win = vim.fn.has("win32") ~= 0
+
local function clean_path(path)
if path == "/" then return path end
path = string.gsub(path, "[/\\]+", "/")
@@ -8,6 +10,7 @@ local function clean_path(path)
end
local function full_path(name)
+ if is_win and string.match(name, "^[a-zA-Z]:[/\\]?$") then return clean_path(name) end
local path = vim.fn.fnamemodify(name, ":p")
return clean_path(path)
end