diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 4560c0a..3077661 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -181,6 +181,8 @@ end function make_entry.gen_from_buffer(opts) opts = opts or {} + local cwd = vim.fn.expand(opts.cwd or vim.fn.getcwd()) + local get_position = function(entry) local tabpage_wins = vim.api.nvim_tabpage_list_wins(0) for k, v in ipairs(tabpage_wins) do @@ -208,6 +210,11 @@ function make_entry.gen_from_buffer(opts) local bufnr_str = tostring(entry) local bufname = vim.api.nvim_buf_get_name(entry) + -- if bufname is inside the cwd, trim that part of the string + if bufname:sub(1, #cwd) == cwd then + bufname = bufname:sub(#cwd + 1, #bufname) + end + local position = get_position(entry) if '' == bufname then