chore: move to plenary.path (#24)

This commit is contained in:
Simon Hauser 2021-07-14 19:54:33 +02:00 committed by GitHub
parent 721300e3d6
commit 5173a42d4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,7 +11,7 @@ local actions = require('telescope.actions')
local conf = require('telescope.config').values
local entry_display = require "telescope.pickers.entry_display"
local finders = require "telescope.finders"
local path = require('telescope.path')
local Path = require('plenary.path')
local pickers = require "telescope.pickers"
local sorters = require "telescope.sorters"
local utils = require('telescope.utils')
@ -37,12 +37,12 @@ local function format_filepath(filename, opts)
local original_filename = filename
if state.active_filter then
filename = path.make_relative(filename, state.active_filter)
filename = Path:new(filename):make_relative(state.active_filter)
else
filename = path.make_relative(filename, state.cwd)
filename = Path:new(filename):make_relative(state.cwd)
-- check relative to home/current
if vim.startswith(filename, os_home) then
filename = "~/" .. path.make_relative(filename, os_home)
filename = "~/" .. Path:new(filename):make_relative(os_home)
elseif filename ~= original_filename then
filename = "./" .. filename
end
@ -95,7 +95,7 @@ local frecency = function(opts)
-- TODO: Only add +1 if opts.show_filter_thing is true, +1 is for the trailing slash
directory_col_width = #(utils.path_tail(state.active_filter)) + 1
else
directory_col_width = #(path.make_relative(state.active_filter, os_home)) + 1
directory_col_width = #(Path:new(state.active_filter):make_relative(os_home)) + 1
end
end
local res = {}
@ -131,7 +131,7 @@ local frecency = function(opts)
if state.active_filter_tag == "LSP" or state.active_filter_tag == "CWD" then
filter_path = utils.path_tail(state.active_filter) .. os_path_sep
else
filter_path = path.make_relative(state.active_filter, os_home) .. os_path_sep
filter_path = Path:new(state.active_filter):make_relative(os_home) .. os_path_sep
end
end
table.insert(display_items, {filter_path, "Directory"})