fix: adapt to Nvim deprecations in 0.10 (#3109)
This commit is contained in:
@@ -12,7 +12,7 @@ local log = require "telescope.log"
|
|||||||
|
|
||||||
local Path = require "plenary.path"
|
local Path = require "plenary.path"
|
||||||
|
|
||||||
local flatten = vim.tbl_flatten
|
local flatten = utils.flatten
|
||||||
local filter = vim.tbl_filter
|
local filter = vim.tbl_filter
|
||||||
|
|
||||||
local files = {}
|
local files = {}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ git.files = function(opts)
|
|||||||
prompt_title = "Git Files",
|
prompt_title = "Git Files",
|
||||||
__locations_input = true,
|
__locations_input = true,
|
||||||
finder = finders.new_oneshot_job(
|
finder = finders.new_oneshot_job(
|
||||||
vim.tbl_flatten {
|
utils.flatten {
|
||||||
opts.git_command,
|
opts.git_command,
|
||||||
show_untracked and "--others" or nil,
|
show_untracked and "--others" or nil,
|
||||||
recurse_submodules and "--recurse-submodules" or nil,
|
recurse_submodules and "--recurse-submodules" or nil,
|
||||||
@@ -193,7 +193,7 @@ git.bcommits = function(opts)
|
|||||||
|
|
||||||
local title = "Git BCommits"
|
local title = "Git BCommits"
|
||||||
local finder = finders.new_oneshot_job(
|
local finder = finders.new_oneshot_job(
|
||||||
vim.tbl_flatten {
|
utils.flatten {
|
||||||
opts.git_command,
|
opts.git_command,
|
||||||
opts.current_file,
|
opts.current_file,
|
||||||
},
|
},
|
||||||
@@ -234,7 +234,7 @@ git.bcommits_range = function(opts)
|
|||||||
|
|
||||||
local title = "Git BCommits in range"
|
local title = "Git BCommits in range"
|
||||||
local finder = finders.new_oneshot_job(
|
local finder = finders.new_oneshot_job(
|
||||||
vim.tbl_flatten {
|
utils.flatten {
|
||||||
opts.git_command,
|
opts.git_command,
|
||||||
line_range,
|
line_range,
|
||||||
},
|
},
|
||||||
@@ -432,7 +432,7 @@ end
|
|||||||
local try_worktrees = function(opts)
|
local try_worktrees = function(opts)
|
||||||
local worktrees = conf.git_worktrees
|
local worktrees = conf.git_worktrees
|
||||||
|
|
||||||
if vim.tbl_islist(worktrees) then
|
if utils.islist(worktrees) then
|
||||||
for _, wt in ipairs(worktrees) do
|
for _, wt in ipairs(worktrees) do
|
||||||
if vim.startswith(opts.cwd, wt.toplevel) then
|
if vim.startswith(opts.cwd, wt.toplevel) then
|
||||||
opts.toplevel = wt.toplevel
|
opts.toplevel = wt.toplevel
|
||||||
|
|||||||
@@ -793,7 +793,7 @@ end
|
|||||||
|
|
||||||
internal.man_pages = function(opts)
|
internal.man_pages = function(opts)
|
||||||
opts.sections = vim.F.if_nil(opts.sections, { "1" })
|
opts.sections = vim.F.if_nil(opts.sections, { "1" })
|
||||||
assert(vim.tbl_islist(opts.sections), "sections should be a list")
|
assert(utils.islist(opts.sections), "sections should be a list")
|
||||||
opts.man_cmd = utils.get_lazy_default(opts.man_cmd, function()
|
opts.man_cmd = utils.get_lazy_default(opts.man_cmd, function()
|
||||||
local uname = vim.loop.os_uname()
|
local uname = vim.loop.os_uname()
|
||||||
local sysname = string.lower(uname.sysname)
|
local sysname = string.lower(uname.sysname)
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ local function list_or_jump(action, title, params, opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local locations = {}
|
local locations = {}
|
||||||
if not vim.tbl_islist(result) then
|
if not utils.islist(result) then
|
||||||
locations = { result }
|
locations = { result }
|
||||||
end
|
end
|
||||||
vim.list_extend(locations, result)
|
vim.list_extend(locations, result)
|
||||||
@@ -393,7 +393,9 @@ lsp.dynamic_workspace_symbols = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function check_capabilities(method, bufnr)
|
local function check_capabilities(method, bufnr)
|
||||||
local clients = vim.lsp.get_active_clients { bufnr = bufnr }
|
--TODO(clason): remove when dropping support for Nvim 0.9
|
||||||
|
local get_clients = vim.fn.has "nvim-0.10" and vim.lsp.get_clients or vim.lsp.get_active_clients
|
||||||
|
local clients = get_clients { bufnr = bufnr }
|
||||||
|
|
||||||
for _, client in pairs(clients) do
|
for _, client in pairs(clients) do
|
||||||
if client.supports_method(method, { bufnr = bufnr }) then
|
if client.supports_method(method, { bufnr = bufnr }) then
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ resolver.resolve_anchor_pos = function(anchor, p_width, p_height, max_columns, m
|
|||||||
return pos
|
return pos
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- duplicate from utils.lua to keep self-contained
|
||||||
-- Win option always returns a table with preview, results, and prompt.
|
-- Win option always returns a table with preview, results, and prompt.
|
||||||
-- It handles many different ways. Some examples are as follows:
|
-- It handles many different ways. Some examples are as follows:
|
||||||
--
|
--
|
||||||
@@ -292,7 +293,8 @@ end
|
|||||||
-- prompt = {...},
|
-- prompt = {...},
|
||||||
-- }
|
-- }
|
||||||
resolver.win_option = function(val, default)
|
resolver.win_option = function(val, default)
|
||||||
if type(val) ~= "table" or vim.tbl_islist(val) then
|
local islist = require("telescope.utils").islist
|
||||||
|
if type(val) ~= "table" or islist(val) then
|
||||||
if val == nil then
|
if val == nil then
|
||||||
val = default
|
val = default
|
||||||
end
|
end
|
||||||
@@ -303,7 +305,7 @@ resolver.win_option = function(val, default)
|
|||||||
prompt = val,
|
prompt = val,
|
||||||
}
|
}
|
||||||
elseif type(val) == "table" then
|
elseif type(val) == "table" then
|
||||||
assert(not vim.tbl_islist(val))
|
assert(not islist(val))
|
||||||
|
|
||||||
local val_to_set = val[1]
|
local val_to_set = val[1]
|
||||||
if val_to_set == nil then
|
if val_to_set == nil then
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ local make_entry = require "telescope.make_entry"
|
|||||||
|
|
||||||
return function(opts)
|
return function(opts)
|
||||||
local input_results
|
local input_results
|
||||||
if vim.tbl_islist(opts) then
|
if require("telescope.utils").islist(opts) then
|
||||||
input_results = opts
|
input_results = opts
|
||||||
else
|
else
|
||||||
input_results = opts.results
|
input_results = opts.results
|
||||||
|
|||||||
@@ -602,10 +602,10 @@ function Picker:find()
|
|||||||
end
|
end
|
||||||
a.nvim_feedkeys(a.nvim_replace_termcodes(keys, true, false, true), "ni", true)
|
a.nvim_feedkeys(a.nvim_replace_termcodes(keys, true, false, true), "ni", true)
|
||||||
else
|
else
|
||||||
utils.notify(
|
utils.notify("pickers.find", {
|
||||||
"pickers.find",
|
msg = "`initial_mode` should be one of ['normal', 'insert'] but passed " .. self.initial_mode,
|
||||||
{ msg = "`initial_mode` should be one of ['normal', 'insert'] but passed " .. self.initial_mode, level = "ERROR" }
|
level = "ERROR",
|
||||||
)
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local main_loop = async.void(function()
|
local main_loop = async.void(function()
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ local bat_maker = function(filename, lnum, start, finish)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return vim.tbl_flatten {
|
return utils.flatten {
|
||||||
command,
|
command,
|
||||||
bat_options,
|
bat_options,
|
||||||
"--",
|
"--",
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ local utils = {}
|
|||||||
|
|
||||||
utils.iswin = vim.loop.os_uname().sysname == "Windows_NT"
|
utils.iswin = vim.loop.os_uname().sysname == "Windows_NT"
|
||||||
|
|
||||||
|
--TODO(clason): Remove when dropping support for Nvim 0.9
|
||||||
|
utils.islist = vim.fn.has "nvim-0.10" == 1 and vim.islist or vim.tbl_islist
|
||||||
|
local flatten = function(t)
|
||||||
|
return vim.iter(t):flatten():totable()
|
||||||
|
end
|
||||||
|
utils.flatten = vim.fn.has "nvim-0.10" == 1 and flatten or vim.tbl_flatten
|
||||||
|
|
||||||
--- Hybrid of `vim.fn.expand()` and custom `vim.fs.normalize()`
|
--- Hybrid of `vim.fn.expand()` and custom `vim.fs.normalize()`
|
||||||
---
|
---
|
||||||
--- Paths starting with '%', '#' or '<' are expanded with `vim.fn.expand()`.
|
--- Paths starting with '%', '#' or '<' are expanded with `vim.fn.expand()`.
|
||||||
|
|||||||
@@ -116,7 +116,13 @@ end, {
|
|||||||
local n = #l - 2
|
local n = #l - 2
|
||||||
|
|
||||||
if n == 0 then
|
if n == 0 then
|
||||||
local commands = vim.tbl_flatten { builtin_list, extensions_list }
|
local commands = { builtin_list, extensions_list }
|
||||||
|
-- TODO(clason): remove when dropping support for Nvim 0.9
|
||||||
|
if vim.fn.has "nvim-0.10" then
|
||||||
|
commands = vim.iter(commands):flatten():totable()
|
||||||
|
else
|
||||||
|
commands = vim.tbl_flatten(commands)
|
||||||
|
end
|
||||||
table.sort(commands)
|
table.sort(commands)
|
||||||
|
|
||||||
return vim.tbl_filter(function(val)
|
return vim.tbl_filter(function(val)
|
||||||
|
|||||||
Reference in New Issue
Block a user