Skip to content

Commit 8cbb89a

Browse files
committed
build: switch to plenary.path2 for improve Windows path support
1 parent 5972437 commit 8cbb89a

File tree

16 files changed

+25
-28
lines changed

16 files changed

+25
-28
lines changed

lua/telescope/actions/history.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local conf = require("telescope.config").values
2-
local Path = require "plenary.path"
2+
local Path = require "plenary.path2"
33
local utils = require "telescope.utils"
44

55
local uv = vim.loop

lua/telescope/actions/set.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
local a = vim.api
1515

1616
local log = require "telescope.log"
17-
local Path = require "plenary.path"
17+
local Path = require "plenary.path2"
1818
local state = require "telescope.state"
1919
local utils = require "telescope.utils"
2020

lua/telescope/actions/utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ end
108108

109109
-- Best effort to infer function names for actions.which_key
110110
function utils._get_anon_function_name(info)
111-
local Path = require "plenary.path"
111+
local Path = require "plenary.path2"
112112
local fname
113113
-- if fn defined in string (ie loadstring) source is string
114114
-- if fn defined in file, source is file name prefixed with a `@´

lua/telescope/algos/fzy.lua

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@
77
-- > matches on consecutive letters and starts of words. This allows matching
88
-- > using acronyms or different parts of the path." - J Hawthorn
99

10-
local has_path, Path = pcall(require, "plenary.path")
11-
if not has_path then
12-
Path = {
13-
path = {
14-
separator = "/",
15-
},
16-
}
17-
end
10+
local Path = require "plenary.path2"
1811

1912
local SCORE_GAP_LEADING = -0.005
2013
local SCORE_GAP_TRAILING = -0.005

lua/telescope/builtin/__files.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ local utils = require "telescope.utils"
1010
local conf = require("telescope.config").values
1111
local log = require "telescope.log"
1212

13-
local Path = require "plenary.path"
13+
local Path = require "plenary.path2"
1414

1515
local flatten = utils.flatten
1616
local filter = vim.tbl_filter

lua/telescope/builtin/__git.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local previewers = require "telescope.previewers"
88
local utils = require "telescope.utils"
99
local entry_display = require "telescope.pickers.entry_display"
1010
local strings = require "plenary.strings"
11-
local Path = require "plenary.path"
11+
local Path = require "plenary.path2"
1212

1313
local conf = require("telescope.config").values
1414
local git_command = utils.__git_command

lua/telescope/builtin/__internal.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local action_set = require "telescope.actions.set"
33
local action_state = require "telescope.actions.state"
44
local finders = require "telescope.finders"
55
local make_entry = require "telescope.make_entry"
6-
local Path = require "plenary.path"
6+
local Path = require "plenary.path2"
77
local pickers = require "telescope.pickers"
88
local previewers = require "telescope.previewers"
99
local p_window = require "telescope.pickers.window"
@@ -319,7 +319,7 @@ internal.symbols = function(opts)
319319

320320
local results = {}
321321
for _, source in ipairs(sources) do
322-
local data = vim.json.decode(Path:new(source):read())
322+
local data = vim.json.decode(assert(Path:new(source):read()))
323323
for _, entry in ipairs(data) do
324324
table.insert(results, entry)
325325
end

lua/telescope/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local strings = require "plenary.strings"
22
local deprecated = require "telescope.deprecated"
33
local sorters = require "telescope.sorters"
4-
local os_sep = require("plenary.path").path.sep
4+
local os_sep = require("plenary.path2").path.sep
55
local has_win = vim.fn.has "win32" == 1
66

77
-- Keep the values around between reloads

lua/telescope/make_entry.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
local entry_display = require "telescope.pickers.entry_display"
3838
local utils = require "telescope.utils"
3939
local strings = require "plenary.strings"
40-
local Path = require "plenary.path"
40+
local Path = require "plenary.path2"
4141

4242
local treesitter_type_highlight = {
4343
["associated"] = "TSConstant",

lua/telescope/previewers/buffer_previewer.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local from_entry = require "telescope.from_entry"
2-
local Path = require "plenary.path"
2+
local Path = require "plenary.path2"
33
local utils = require "telescope.utils"
44
local putils = require "telescope.previewers.utils"
55
local Previewer = require "telescope.previewers.previewer"
@@ -98,7 +98,7 @@ color_hash[6] = function(line)
9898
end
9999

100100
local colorize_ls_long = function(bufnr, data, sections)
101-
local windows_add = Path.path.sep == "\\" and 2 or 0
101+
local windows_add = utils.iswin and 2 or 0
102102
for lnum, line in ipairs(data) do
103103
local section = sections[lnum]
104104
for i = 1, section[1].end_index - 1 do -- Highlight permissions
@@ -125,7 +125,7 @@ local handle_directory_preview = function(filepath, bufnr, opts)
125125
local set_colorize_lines
126126
if opts.preview.ls_short then
127127
set_colorize_lines = function(data, sections)
128-
local PATH_SECTION = Path.path.sep == "\\" and 4 or 6
128+
local PATH_SECTION = utils.iswin and 4 or 6
129129
local paths = {}
130130
for i, line in ipairs(data) do
131131
local section = sections[i][PATH_SECTION]
@@ -195,7 +195,7 @@ local handle_file_preview = function(filepath, bufnr, stat, opts)
195195
end
196196

197197
opts.start_time = vim.loop.hrtime()
198-
Path:new(filepath):_read_async(vim.schedule_wrap(function(data)
198+
Path:new(filepath):read(vim.schedule_wrap(function(data)
199199
if not vim.api.nvim_buf_is_valid(bufnr) then
200200
return
201201
end

0 commit comments

Comments
 (0)