Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/telescope/actions/history.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local conf = require("telescope.config").values
local Path = require "plenary.path"
local Path = require "plenary.path2"
local utils = require "telescope.utils"

local uv = vim.loop
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/actions/set.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
local a = vim.api

local log = require "telescope.log"
local Path = require "plenary.path"
local Path = require "plenary.path2"
local state = require "telescope.state"
local utils = require "telescope.utils"

Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/actions/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ end

-- Best effort to infer function names for actions.which_key
function utils._get_anon_function_name(info)
local Path = require "plenary.path"
local Path = require "plenary.path2"
local fname
-- if fn defined in string (ie loadstring) source is string
-- if fn defined in file, source is file name prefixed with a `@´
Expand Down
9 changes: 1 addition & 8 deletions lua/telescope/algos/fzy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
-- > matches on consecutive letters and starts of words. This allows matching
-- > using acronyms or different parts of the path." - J Hawthorn

local has_path, Path = pcall(require, "plenary.path")
if not has_path then
Path = {
path = {
separator = "/",
},
}
end
local Path = require "plenary.path2"

local SCORE_GAP_LEADING = -0.005
local SCORE_GAP_TRAILING = -0.005
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/builtin/__files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local utils = require "telescope.utils"
local conf = require("telescope.config").values
local log = require "telescope.log"

local Path = require "plenary.path"
local Path = require "plenary.path2"

local flatten = utils.flatten
local filter = vim.tbl_filter
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/builtin/__git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local previewers = require "telescope.previewers"
local utils = require "telescope.utils"
local entry_display = require "telescope.pickers.entry_display"
local strings = require "plenary.strings"
local Path = require "plenary.path"
local Path = require "plenary.path2"

local conf = require("telescope.config").values
local git_command = utils.__git_command
Expand Down
4 changes: 2 additions & 2 deletions lua/telescope/builtin/__internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local action_set = require "telescope.actions.set"
local action_state = require "telescope.actions.state"
local finders = require "telescope.finders"
local make_entry = require "telescope.make_entry"
local Path = require "plenary.path"
local Path = require "plenary.path2"
local pickers = require "telescope.pickers"
local previewers = require "telescope.previewers"
local p_window = require "telescope.pickers.window"
Expand Down Expand Up @@ -319,7 +319,7 @@ internal.symbols = function(opts)

local results = {}
for _, source in ipairs(sources) do
local data = vim.json.decode(Path:new(source):read())
local data = vim.json.decode(assert(Path:new(source):read()))
for _, entry in ipairs(data) do
table.insert(results, entry)
end
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/config.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local strings = require "plenary.strings"
local deprecated = require "telescope.deprecated"
local sorters = require "telescope.sorters"
local os_sep = require("plenary.path").path.sep
local os_sep = require("plenary.path2").path.sep
local has_win = vim.fn.has "win32" == 1

-- Keep the values around between reloads
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/make_entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
local entry_display = require "telescope.pickers.entry_display"
local utils = require "telescope.utils"
local strings = require "plenary.strings"
local Path = require "plenary.path"
local Path = require "plenary.path2"

local treesitter_type_highlight = {
["associated"] = "TSConstant",
Expand Down
8 changes: 4 additions & 4 deletions lua/telescope/previewers/buffer_previewer.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local from_entry = require "telescope.from_entry"
local Path = require "plenary.path"
local Path = require "plenary.path2"
local utils = require "telescope.utils"
local putils = require "telescope.previewers.utils"
local Previewer = require "telescope.previewers.previewer"
Expand Down Expand Up @@ -98,7 +98,7 @@ color_hash[6] = function(line)
end

local colorize_ls_long = function(bufnr, data, sections)
local windows_add = Path.path.sep == "\\" and 2 or 0
local windows_add = utils.iswin and 2 or 0
for lnum, line in ipairs(data) do
local section = sections[lnum]
for i = 1, section[1].end_index - 1 do -- Highlight permissions
Expand All @@ -125,7 +125,7 @@ local handle_directory_preview = function(filepath, bufnr, opts)
local set_colorize_lines
if opts.preview.ls_short then
set_colorize_lines = function(data, sections)
local PATH_SECTION = Path.path.sep == "\\" and 4 or 6
local PATH_SECTION = utils.iswin and 4 or 6
local paths = {}
for i, line in ipairs(data) do
local section = sections[i][PATH_SECTION]
Expand Down Expand Up @@ -195,7 +195,7 @@ local handle_file_preview = function(filepath, bufnr, stat, opts)
end

opts.start_time = vim.loop.hrtime()
Path:new(filepath):_read_async(vim.schedule_wrap(function(data)
Path:new(filepath):read(vim.schedule_wrap(function(data)
if not vim.api.nvim_buf_is_valid(bufnr) then
return
end
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/previewers/term_previewer.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local conf = require("telescope.config").values
local utils = require "telescope.utils"
local Path = require "plenary.path"
local Path = require "plenary.path2"
local from_entry = require "telescope.from_entry"
local Previewer = require "telescope.previewers.previewer"
local putil = require "telescope.previewers.utils"
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/previewers/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local strings = require "plenary.strings"
local conf = require("telescope.config").values

local Job = require "plenary.job"
local Path = require "plenary.path"
local Path = require "plenary.path2"

local telescope_utils = require "telescope.utils"

Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/testharness/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local assert = require "luassert"

local Path = require "plenary.path"
local Path = require "plenary.path2"

local tester = {}
tester.debug = false
Expand Down
10 changes: 7 additions & 3 deletions lua/telescope/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
--- Utilities for writing telescope pickers
---@brief ]]

local Path = require "plenary.path"
local Path = require "plenary.path2"
local Job = require "plenary.job"

local log = require "telescope.log"
Expand Down Expand Up @@ -223,7 +223,11 @@ local path_abs = function(path, opts)
else
cwd = vim.loop.cwd()
end
return Path:new(path):make_relative(cwd)
local p = Path:new(path)
if p:is_absolute() then
return Path:new(path):make_relative(cwd, { walk_up = true })
end
return p.filename
end

-- IMPORTANT: This function should have been a local function as it's only used
Expand Down Expand Up @@ -385,7 +389,7 @@ utils.transform_path = function(opts, path)
length = shorten.len
exclude = shorten.exclude
else
length = type(path_display["shorten"]) == "number" and path_display["shorten"]
length = type(path_display["shorten"]) == "number" and path_display["shorten"] or nil
end

transformed_path = path_shorten(transformed_path, length, exclude)
Expand Down
6 changes: 3 additions & 3 deletions lua/tests/automated/telescope_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local picker = require "telescope.pickers"
local Path = require "plenary.path"
local Path = require "plenary.path2"

local eq = assert.are.same

Expand Down Expand Up @@ -108,7 +108,7 @@ describe("telescope", function()
describe("fzy", function()
local sorter = require("telescope.sorters").get_fzy_sorter()
local function score(prompt, line)
line = new_path(line)
line = Path.is_path(line) and line.filename or new_path(line)
return sorter:score(prompt, { ordinal = line }, function(val)
return val
end, function()
Expand Down Expand Up @@ -167,7 +167,7 @@ describe("telescope", function()
end)
it("prefers matches at the beginning", function()
assert.True(score("ab", "abbb") < score("ab", "babb"))
assert.True(score("test", "testing") < score("test", "/testing"))
assert.True(score("test", "testing") < score("test", Path:new { Path.path.root(), "testing" }))
end)
it("prefers matches at some locations", function()
assert.True(score("a", "/a") < score("a", "ba"))
Expand Down
2 changes: 1 addition & 1 deletion lua/tests/automated/utils_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local Path = require "plenary.path"
local Path = require "plenary.path2"
local utils = require "telescope.utils"

local eq = assert.are.equal
Expand Down
Loading