doc: fix typecheck errors in nvim 0.11
This commit is contained in:
parent
ba1f50a9a8
commit
5b38bfe279
4 changed files with 53 additions and 21 deletions
|
|
@ -229,13 +229,24 @@ M.open_terminal = {
|
||||||
assert(dir, "Oil buffer with files adapter must have current directory")
|
assert(dir, "Oil buffer with files adapter must have current directory")
|
||||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_set_current_buf(bufnr)
|
vim.api.nvim_set_current_buf(bufnr)
|
||||||
|
if vim.fn.has("nvim-0.11") == 1 then
|
||||||
|
vim.fn.jobstart(vim.o.shell, { cwd = dir, term = true })
|
||||||
|
else
|
||||||
|
---@diagnostic disable-next-line: deprecated
|
||||||
vim.fn.termopen(vim.o.shell, { cwd = dir })
|
vim.fn.termopen(vim.o.shell, { cwd = dir })
|
||||||
|
end
|
||||||
elseif adapter.name == "ssh" then
|
elseif adapter.name == "ssh" then
|
||||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_set_current_buf(bufnr)
|
vim.api.nvim_set_current_buf(bufnr)
|
||||||
local url = require("oil.adapters.ssh").parse_url(bufname)
|
local url = require("oil.adapters.ssh").parse_url(bufname)
|
||||||
local cmd = require("oil.adapters.ssh.connection").create_ssh_command(url)
|
local cmd = require("oil.adapters.ssh.connection").create_ssh_command(url)
|
||||||
local term_id = vim.fn.termopen(cmd)
|
local term_id
|
||||||
|
if vim.fn.has("nvim-0.11") == 1 then
|
||||||
|
term_id = vim.fn.jobstart(cmd, { term = true })
|
||||||
|
else
|
||||||
|
---@diagnostic disable-next-line: deprecated
|
||||||
|
term_id = vim.fn.termopen(cmd)
|
||||||
|
end
|
||||||
if term_id then
|
if term_id then
|
||||||
vim.api.nvim_chan_send(term_id, string.format("cd %s\n", url.path))
|
vim.api.nvim_chan_send(term_id, string.format("cd %s\n", url.path))
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,10 @@ local win_addslash = function(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class oil.WindowsTrashInfo
|
---@class oil.WindowsTrashInfo
|
||||||
---@field trash_file string?
|
---@field trash_file string
|
||||||
---@field original_path string?
|
---@field original_path string
|
||||||
---@field deletion_date string?
|
---@field deletion_date integer
|
||||||
---@field info_file string?
|
---@field info_file? string
|
||||||
|
|
||||||
---@param url string
|
---@param url string
|
||||||
---@param column_defs string[]
|
---@param column_defs string[]
|
||||||
|
|
@ -96,6 +96,7 @@ M.list = function(url, column_defs, cb)
|
||||||
end
|
end
|
||||||
cache_entry[FIELD_META] = {
|
cache_entry[FIELD_META] = {
|
||||||
stat = nil,
|
stat = nil,
|
||||||
|
---@type oil.WindowsTrashInfo
|
||||||
trash_info = {
|
trash_info = {
|
||||||
trash_file = entry.Path,
|
trash_file = entry.Path,
|
||||||
original_path = entry.OriginalPath,
|
original_path = entry.OriginalPath,
|
||||||
|
|
|
||||||
|
|
@ -167,8 +167,13 @@ local function will_file_operation(method, capability_name, files, options)
|
||||||
}
|
}
|
||||||
end, matching_files),
|
end, matching_files),
|
||||||
}
|
}
|
||||||
---@diagnostic disable-next-line: invisible
|
local result, err
|
||||||
local result, err = client.request_sync(method, params, options.timeout_ms or 1000, 0)
|
if vim.fn.has("nvim-0.11") == 1 then
|
||||||
|
result, err = client:request_sync(method, params, options.timeout_ms or 1000, 0)
|
||||||
|
else
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
|
result, err = client.request_sync(method, params, options.timeout_ms or 1000, 0)
|
||||||
|
end
|
||||||
if result and result.result then
|
if result and result.result then
|
||||||
if options.apply_edits ~= false then
|
if options.apply_edits ~= false then
|
||||||
vim.lsp.util.apply_workspace_edit(result.result, client.offset_encoding)
|
vim.lsp.util.apply_workspace_edit(result.result, client.offset_encoding)
|
||||||
|
|
@ -204,11 +209,15 @@ local function did_file_operation(method, capability_name, files)
|
||||||
}
|
}
|
||||||
end, matching_files),
|
end, matching_files),
|
||||||
}
|
}
|
||||||
---@diagnostic disable-next-line: invisible
|
if vim.fn.has("nvim-0.11") == 1 then
|
||||||
|
client:notify(method, params)
|
||||||
|
else
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
client.notify(method, params)
|
client.notify(method, params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Notify the server that the client is about to create files.
|
--- Notify the server that the client is about to create files.
|
||||||
---@param files string[] The files and folders that will be created
|
---@param files string[] The files and folders that will be created
|
||||||
|
|
@ -280,9 +289,15 @@ function M.will_rename_files(files, options)
|
||||||
}
|
}
|
||||||
end, matching_files),
|
end, matching_files),
|
||||||
}
|
}
|
||||||
local result, err =
|
local result, err
|
||||||
---@diagnostic disable-next-line: invisible
|
if vim.fn.has("nvim-0.11") == 1 then
|
||||||
|
result, err =
|
||||||
|
client:request_sync(ms.workspace_willRenameFiles, params, options.timeout_ms or 1000, 0)
|
||||||
|
else
|
||||||
|
result, err =
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
client.request_sync(ms.workspace_willRenameFiles, params, options.timeout_ms or 1000, 0)
|
client.request_sync(ms.workspace_willRenameFiles, params, options.timeout_ms or 1000, 0)
|
||||||
|
end
|
||||||
if result and result.result then
|
if result and result.result then
|
||||||
if options.apply_edits ~= false then
|
if options.apply_edits ~= false then
|
||||||
vim.lsp.util.apply_workspace_edit(result.result, client.offset_encoding)
|
vim.lsp.util.apply_workspace_edit(result.result, client.offset_encoding)
|
||||||
|
|
@ -313,10 +328,14 @@ function M.did_rename_files(files)
|
||||||
}
|
}
|
||||||
end, matching_files),
|
end, matching_files),
|
||||||
}
|
}
|
||||||
---@diagnostic disable-next-line: invisible
|
if vim.fn.has("nvim-0.11") == 1 then
|
||||||
|
client:notify(ms.workspace_didRenameFiles, params)
|
||||||
|
else
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
client.notify(ms.workspace_didRenameFiles, params)
|
client.notify(ms.workspace_didRenameFiles, params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
|
|
@ -363,7 +363,12 @@ M.set_highlights = function(bufnr, highlights)
|
||||||
local ns = vim.api.nvim_create_namespace("Oil")
|
local ns = vim.api.nvim_create_namespace("Oil")
|
||||||
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
||||||
for _, hl in ipairs(highlights) do
|
for _, hl in ipairs(highlights) do
|
||||||
vim.api.nvim_buf_add_highlight(bufnr, ns, unpack(hl))
|
local group, line, col_start, col_end = unpack(hl)
|
||||||
|
vim.api.nvim_buf_set_extmark(bufnr, ns, line, col_start, {
|
||||||
|
end_col = col_end,
|
||||||
|
hl_group = group,
|
||||||
|
strict = false,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -638,11 +643,7 @@ M.render_text = function(bufnr, text, opts)
|
||||||
pcall(vim.api.nvim_buf_set_lines, bufnr, 0, -1, false, lines)
|
pcall(vim.api.nvim_buf_set_lines, bufnr, 0, -1, false, lines)
|
||||||
vim.bo[bufnr].modifiable = false
|
vim.bo[bufnr].modifiable = false
|
||||||
vim.bo[bufnr].modified = false
|
vim.bo[bufnr].modified = false
|
||||||
local ns = vim.api.nvim_create_namespace("Oil")
|
M.set_highlights(bufnr, highlights)
|
||||||
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
|
||||||
for _, hl in ipairs(highlights) do
|
|
||||||
vim.api.nvim_buf_add_highlight(bufnr, ns, unpack(hl))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Run a function in the context of a full-editor window
|
---Run a function in the context of a full-editor window
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue