expand paths more smartly (#2599)

This commit is contained in:
James Trew
2023-07-21 18:12:29 -04:00
committed by GitHub
parent 597a3cc889
commit f52ea4061d
8 changed files with 30 additions and 24 deletions

View File

@@ -13,17 +13,17 @@ local bat_options = { "--style=plain", "--color=always", "--paging=always" }
local has_less = (vim.fn.executable "less" == 1) and conf.use_less
local get_file_stat = function(filename)
return vim.loop.fs_stat(vim.fn.expand(filename)) or {}
return vim.loop.fs_stat(utils.smart_path_expand(filename)) or {}
end
local list_dir = (function()
if vim.fn.has "win32" == 1 then
return function(dirname)
return { "cmd.exe", "/c", "dir", vim.fn.expand(dirname) }
return { "cmd.exe", "/c", "dir", utils.smart_path_expand(dirname) }
end
else
return function(dirname)
return { "ls", "-la", vim.fn.expand(dirname) }
return { "ls", "-la", utils.smart_path_expand(dirname) }
end
end
end)()
@@ -55,7 +55,7 @@ local bat_maker = function(filename, lnum, start, finish)
command,
bat_options,
"--",
vim.fn.expand(filename),
utils.smart_path_expand(filename),
}
end
@@ -74,15 +74,15 @@ local cat_maker = function(filename, _, start, _)
if has_less then
if start then
return { "less", "-RS", string.format("+%s", start), vim.fn.expand(filename) }
return { "less", "-RS", string.format("+%s", start), utils.smart_path_expand(filename) }
else
return { "less", "-RS", vim.fn.expand(filename) }
return { "less", "-RS", utils.smart_path_expand(filename) }
end
else
return {
"cat",
"--",
vim.fn.expand(filename),
utils.smart_path_expand(filename),
}
end
end