doc: fix typecheck errors in nvim 0.11

This commit is contained in:
Steven Arcangeli 2025-03-30 21:56:41 -07:00
parent ba1f50a9a8
commit 5b38bfe279
4 changed files with 53 additions and 21 deletions

View file

@ -229,13 +229,24 @@ M.open_terminal = {
assert(dir, "Oil buffer with files adapter must have current directory")
local bufnr = vim.api.nvim_create_buf(false, true)
vim.api.nvim_set_current_buf(bufnr)
vim.fn.termopen(vim.o.shell, { cwd = dir })
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 })
end
elseif adapter.name == "ssh" then
local bufnr = vim.api.nvim_create_buf(false, true)
vim.api.nvim_set_current_buf(bufnr)
local url = require("oil.adapters.ssh").parse_url(bufname)
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
vim.api.nvim_chan_send(term_id, string.format("cd %s\n", url.path))
end

View file

@ -37,10 +37,10 @@ local win_addslash = function(path)
end
---@class oil.WindowsTrashInfo
---@field trash_file string?
---@field original_path string?
---@field deletion_date string?
---@field info_file string?
---@field trash_file string
---@field original_path string
---@field deletion_date integer
---@field info_file? string
---@param url string
---@param column_defs string[]
@ -96,6 +96,7 @@ M.list = function(url, column_defs, cb)
end
cache_entry[FIELD_META] = {
stat = nil,
---@type oil.WindowsTrashInfo
trash_info = {
trash_file = entry.Path,
original_path = entry.OriginalPath,

View file

@ -167,8 +167,13 @@ local function will_file_operation(method, capability_name, files, options)
}
end, matching_files),
}
---@diagnostic disable-next-line: invisible
local result, err = client.request_sync(method, params, options.timeout_ms or 1000, 0)
local result, err
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 options.apply_edits ~= false then
vim.lsp.util.apply_workspace_edit(result.result, client.offset_encoding)
@ -204,8 +209,12 @@ local function did_file_operation(method, capability_name, files)
}
end, matching_files),
}
---@diagnostic disable-next-line: invisible
client.notify(method, params)
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)
end
end
end
end
@ -280,9 +289,15 @@ function M.will_rename_files(files, options)
}
end, matching_files),
}
local result, err =
---@diagnostic disable-next-line: invisible
client.request_sync(ms.workspace_willRenameFiles, params, options.timeout_ms or 1000, 0)
local result, err
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)
end
if result and result.result then
if options.apply_edits ~= false then
vim.lsp.util.apply_workspace_edit(result.result, client.offset_encoding)
@ -313,8 +328,12 @@ function M.did_rename_files(files)
}
end, matching_files),
}
---@diagnostic disable-next-line: invisible
client.notify(ms.workspace_didRenameFiles, params)
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)
end
end
end
end

View file

@ -363,7 +363,12 @@ M.set_highlights = function(bufnr, highlights)
local ns = vim.api.nvim_create_namespace("Oil")
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))
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
@ -638,11 +643,7 @@ M.render_text = function(bufnr, text, opts)
pcall(vim.api.nvim_buf_set_lines, bufnr, 0, -1, false, lines)
vim.bo[bufnr].modifiable = false
vim.bo[bufnr].modified = false
local ns = vim.api.nvim_create_namespace("Oil")
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
M.set_highlights(bufnr, highlights)
end
---Run a function in the context of a full-editor window