expand paths more smartly (#2599)
This commit is contained in:
@@ -256,7 +256,7 @@ previewers.file_maker = function(filepath, bufnr, opts)
|
||||
end
|
||||
if opts.bufname ~= filepath then
|
||||
if not vim.in_fast_event() then
|
||||
filepath = vim.fn.expand(filepath)
|
||||
filepath = utils.smart_path_expand(filepath)
|
||||
end
|
||||
vim.loop.fs_stat(filepath, function(_, stat)
|
||||
if not stat then
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user