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

@@ -96,12 +96,12 @@ files.live_grep = function(opts)
local vimgrep_arguments = opts.vimgrep_arguments or conf.vimgrep_arguments
local search_dirs = opts.search_dirs
local grep_open_files = opts.grep_open_files
opts.cwd = opts.cwd and vim.fn.expand(opts.cwd) or vim.loop.cwd()
opts.cwd = utils.smart_path_expand(opts.cwd or vim.loop.cwd())
local filelist = get_open_filelist(grep_open_files, opts.cwd)
if search_dirs then
for i, path in ipairs(search_dirs) do
search_dirs[i] = vim.fn.expand(path)
search_dirs[i] = utils.smart_path_expand(path)
end
end
@@ -166,7 +166,7 @@ files.live_grep = function(opts)
end
files.grep_string = function(opts)
opts.cwd = opts.cwd and vim.fn.expand(opts.cwd) or vim.loop.cwd()
opts.cwd = utils.smart_path_expand(opts.cwd or vim.loop.cwd())
local vimgrep_arguments = vim.F.if_nil(opts.vimgrep_arguments, conf.vimgrep_arguments)
local word
local visual = vim.fn.mode() == "v"
@@ -225,7 +225,7 @@ files.grep_string = function(opts)
end
elseif opts.search_dirs then
for _, path in ipairs(opts.search_dirs) do
table.insert(args, vim.fn.expand(path))
table.insert(args, utils.smart_path_expand(path))
end
end
@@ -278,7 +278,7 @@ files.find_files = function(opts)
if search_dirs then
for k, v in pairs(search_dirs) do
search_dirs[k] = vim.fn.expand(v)
search_dirs[k] = utils.smart_path_expand(v)
end
end
@@ -355,7 +355,7 @@ files.find_files = function(opts)
end
if opts.cwd then
opts.cwd = vim.fn.expand(opts.cwd)
opts.cwd = utils.smart_path_expand(opts.cwd)
end
opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts)
@@ -444,7 +444,7 @@ end
files.current_buffer_fuzzy_find = function(opts)
-- All actions are on the current buffer
local filename = vim.fn.expand(vim.api.nvim_buf_get_name(opts.bufnr))
local filename = utils.smart_path_expand(vim.api.nvim_buf_get_name(opts.bufnr))
local filetype = vim.api.nvim_buf_get_option(opts.bufnr, "filetype")
local lines = vim.api.nvim_buf_get_lines(opts.bufnr, 0, -1, false)
@@ -548,7 +548,7 @@ files.tags = function(opts)
local tagfiles = opts.ctags_file and { opts.ctags_file } or vim.fn.tagfiles()
for i, ctags_file in ipairs(tagfiles) do
tagfiles[i] = vim.fn.expand(ctags_file, true)
tagfiles[i] = utils.smart_path_expand(ctags_file, true)
end
if vim.tbl_isempty(tagfiles) then
utils.notify("builtin.tags", {