diff options
| author | Rui Marques <mail@ruimarques.xyz> | 2020-09-21 21:31:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-21 15:31:28 -0400 |
| commit | 2ca006fc97affe237fbbd9b728f2602cf07455e7 (patch) | |
| tree | 831e67f154101f481ee3e170ebb1fe457e4f2442 /lua/telescope/make_entry.lua | |
| parent | 9f863d40bde9a188c998874c0bff2edaf036e5a4 (diff) | |
feat: Trim cwd from bufname if possible (#104)
Diffstat (limited to 'lua/telescope/make_entry.lua')
| -rw-r--r-- | lua/telescope/make_entry.lua | 7 |
1 files changed, 7 insertions, 0 deletions
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 |
