refactor: move from telescope.path to plenary.path (#473)

This will deprecate telescope.path, we will remove it soon. Please move over to plenary.path

Co-authored-by: Simon Hauser <Simon-Hauser@outlook.de>
This commit is contained in:
anott03
2021-07-14 13:25:00 -04:00
committed by GitHub
parent a4896e5ef3
commit df579bac42
11 changed files with 100 additions and 69 deletions

View File

@@ -1,8 +1,6 @@
local entry_display = require('telescope.pickers.entry_display')
local path = require('telescope.path')
local utils = require('telescope.utils')
local strings = require('plenary.strings')
local Path = require('plenary.path')
local treesitter_type_highlight = {
@@ -88,7 +86,7 @@ do
if raw then return raw end
if k == "path" then
local retpath = t.cwd .. path.separator .. t.value
local retpath = Path:new({t.cwd, t.value}):absolute()
if not vim.loop.fs_access(retpath, "R", nil) then
retpath = t.value
end
@@ -146,7 +144,7 @@ do
if Path:new(t.filename):is_absolute() then
return t.filename, false
else
return t.cwd .. path.separator .. t.filename, false
return Path:new({t.cwd, t.filename}):absolute(), false
end
end,
@@ -446,7 +444,7 @@ function make_entry.gen_from_buffer(opts)
return function(entry)
local bufname = entry.info.name ~= "" and entry.info.name or '[No Name]'
-- if bufname is inside the cwd, trim that part of the string
bufname = path.normalize(bufname, cwd)
bufname = Path:new(bufname):normalize(cwd)
local hidden = entry.info.hidden == 1 and 'h' or 'a'
local readonly = vim.api.nvim_buf_get_option(entry.bufnr, 'readonly') and '=' or ' '
@@ -815,7 +813,7 @@ function make_entry.gen_from_ctags(opts)
opts = opts or {}
local cwd = vim.fn.expand(opts.cwd or vim.fn.getcwd())
local current_file = path.normalize(vim.fn.expand('%'), cwd)
local current_file = Path:new(vim.fn.expand('%')):normalize(cwd)
local display_items = {
{ remaining = true },
@@ -1106,10 +1104,9 @@ function make_entry.gen_from_git_status(opts)
status = mod,
ordinal = entry,
display = make_display,
path = opts.cwd .. path.separator .. file
path = Path:new({opts.cwd, file}):absolute()
}
end
end
return make_entry