From 60660334c70d9d81dccc10a563e01920b9455e76 Mon Sep 17 00:00:00 2001 From: tami5 <65782666+tami5@users.noreply.github.com> Date: Mon, 20 Sep 2021 12:52:59 +0300 Subject: feat(defaults): enable customization of path_display.truncate (#1264) followup to https://github.com/nvim-telescope/telescope.nvim/pull/1254 and implementation of https://github.com/nvim-telescope/telescope.nvim/pull/1254#issuecomment-922527270 --- lua/telescope/utils.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lua/telescope/utils.lua') diff --git a/lua/telescope/utils.lua b/lua/telescope/utils.lua index f145184..f19e973 100644 --- a/lua/telescope/utils.lua +++ b/lua/telescope/utils.lua @@ -329,9 +329,10 @@ local is_uri = function(filename) return string.match(filename, "^%w+://") ~= nil end -local calc_result_length = function() +local calc_result_length = function(truncate_len) local status = get_status(vim.api.nvim_get_current_buf()) - return vim.api.nvim_win_get_width(status.results_win) - status.picker.selection_caret:len() - 2 + local len = vim.api.nvim_win_get_width(status.results_win) - status.picker.selection_caret:len() - 2 + return type(truncate_len) == "number" and len - truncate_len or len end utils.transform_path = function(opts, path) @@ -371,7 +372,7 @@ utils.transform_path = function(opts, path) end if vim.tbl_contains(path_display, "truncate") or path_display.truncate then if opts.__length == nil then - opts.__length = calc_result_length() + opts.__length = calc_result_length(path_display.truncate) end transformed_path = truncate(transformed_path, opts.__length, nil, -1) end -- cgit v1.2.3