summaryrefslogtreecommitdiff
path: root/lua/telescope
diff options
context:
space:
mode:
authorLuke Kershaw <35707277+l-kershaw@users.noreply.github.com>2021-07-18 12:19:27 +0100
committerGitHub <noreply@github.com>2021-07-18 12:19:27 +0100
commit8c3f2b630be0241fe10709e61ee9dab473518f32 (patch)
tree2fb76dda2bfc2d9152dc685f9c79ba5c70f795ac /lua/telescope
parent1bb73aed5f4bd1e00a0b3cbe03f2aaa42bad4e52 (diff)
feat: check type of `path_display` and warn user if wrong (#1023)
Diffstat (limited to 'lua/telescope')
-rw-r--r--lua/telescope/utils.lua47
1 files changed, 26 insertions, 21 deletions
diff --git a/lua/telescope/utils.lua b/lua/telescope/utils.lua
index 6e35b81..eb59962 100644
--- a/lua/telescope/utils.lua
+++ b/lua/telescope/utils.lua
@@ -281,34 +281,39 @@ utils.transform_path = function(opts, path)
if type(path_display) == "function" then
return path_display(opts, transformed_path)
- end
- if utils.is_path_hidden(nil, path_display) then
- return ''
- end
+ elseif utils.is_path_hidden(nil, path_display) then
+ return ''
- if vim.tbl_contains(path_display, "tail") or path_display.tail then
- transformed_path = utils.path_tail(transformed_path)
- else
- if not vim.tbl_contains(path_display, "absolute") or path_display.absolute == false then
- local cwd
- if opts.cwd then
- cwd = opts.cwd
- if not vim.in_fast_event() then
- cwd = vim.fn.expand(opts.cwd)
+ elseif type(path_display) == "table" then
+
+ if vim.tbl_contains(path_display, "tail") or path_display.tail then
+ transformed_path = utils.path_tail(transformed_path)
+ else
+ if not vim.tbl_contains(path_display, "absolute") or path_display.absolute == false then
+ local cwd
+ if opts.cwd then
+ cwd = opts.cwd
+ if not vim.in_fast_event() then
+ cwd = vim.fn.expand(opts.cwd)
+ end
+ else
+ cwd = vim.loop.cwd();
end
- else
- cwd = vim.loop.cwd();
+ transformed_path = Path:new(transformed_path):make_relative(cwd)
end
- transformed_path = Path:new(transformed_path):make_relative(cwd)
- end
- if vim.tbl_contains(path_display, "shorten") or path_display["shorten"] ~= nil then
- transformed_path = Path:new(transformed_path):shorten(path_display["shorten"])
+ if vim.tbl_contains(path_display, "shorten") or path_display["shorten"] ~= nil then
+ transformed_path = Path:new(transformed_path):shorten(path_display["shorten"])
+ end
end
- end
- return transformed_path
+ return transformed_path
+ else
+ log.warn("`path_display` must be either a function or a table.",
+ "See `:help telescope.defaults.path_display.")
+ return transformed_path
+ end
end
-- local x = utils.make_default_callable(function(opts)