diff options
| author | anott03 <amitav_nott@ryecountryday.org> | 2021-07-14 13:25:00 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-14 19:25:00 +0200 |
| commit | df579bac425e4b6b69a0c8e694b154610cd5420b (patch) | |
| tree | fc4eb1bcbeeabe199bd997757bd72892fb4c07a0 /lua/telescope/utils.lua | |
| parent | a4896e5ef39a8006a8251d48d4cf24aac81a4f94 (diff) | |
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>
Diffstat (limited to 'lua/telescope/utils.lua')
| -rw-r--r-- | lua/telescope/utils.lua | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/lua/telescope/utils.lua b/lua/telescope/utils.lua index b8d2b6b..bb48c2c 100644 --- a/lua/telescope/utils.lua +++ b/lua/telescope/utils.lua @@ -1,12 +1,12 @@ local has_devicons, devicons = pcall(require, 'nvim-web-devicons') -local pathlib = require('telescope.path') +local Path = require('plenary.path') local Job = require('plenary.job') local utils = {} utils.get_separator = function() - return pathlib.separator + return Path.path.sep end utils.if_nil = function(x, was_nil, was_not_nil) @@ -251,21 +251,6 @@ utils.diagnostics_to_tbl = function(opts) return items end --- TODO: Figure out how to do this... could include in plenary :) --- NOTE: Don't use this yet. It will segfault sometimes. --- --- opts.shorten_path and function(value) --- local result = { --- valid = true, --- display = utils.path_shorten(value), --- ordinal = value, --- value = value --- } - --- return result --- end or nil) -utils.path_shorten = pathlib.shorten - utils.path_tail = (function() local os_sep = utils.get_separator() local match_string = '[^' .. os_sep .. ']*$' @@ -304,11 +289,11 @@ utils.transform_path = function(opts, path) else cwd = vim.loop.cwd(); end - transformed_path = pathlib.make_relative(transformed_path, cwd) + transformed_path = Path:new(transformed_path):make_relative(cwd) end if vim.tbl_contains(path_display, "shorten") then - transformed_path = pathlib.shorten(transformed_path) + transformed_path = Path:new(transformed_path):shorten() end end @@ -397,7 +382,7 @@ function utils.data_directory() local sourced_file = require('plenary.debug_utils').sourced_filepath() local base_directory = vim.fn.fnamemodify(sourced_file, ":h:h:h") - return base_directory .. pathlib.separator .. 'data' .. pathlib.separator + return Path:new({base_directory, 'data'}):absolute() .. Path.path.sep end function utils.display_termcodes(str) |
