diff --git a/doc/telescope.txt b/doc/telescope.txt index e479d1e..de019dd 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -192,7 +192,8 @@ telescope.setup({opts}) *telescope.setup()* - "shorten" only display the first character of each directory in the path - "truncate" truncates the start of the path when the whole path will - not fit + not fit. To increase the the gap between the path and the edge. + set truncate to number `truncate = 3` You can also specify the number of characters of each directory name to keep by setting `path_display.shorten = num`. diff --git a/lua/telescope/config.lua b/lua/telescope/config.lua index 7a54ec3..37ca919 100644 --- a/lua/telescope/config.lua +++ b/lua/telescope/config.lua @@ -257,7 +257,8 @@ append( - "shorten" only display the first character of each directory in the path - "truncate" truncates the start of the path when the whole path will - not fit + not fit. To increase the the gap between the path and the edge. + set truncate to number `truncate = 3` You can also specify the number of characters of each directory name to keep by setting `path_display.shorten = num`. 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