lint: stricter type checking

This commit is contained in:
Steven Arcangeli 2024-08-30 17:09:56 -07:00
parent f60bb7f793
commit 1360be5fda
9 changed files with 25 additions and 3 deletions

9
.luarc.json Normal file
View file

@ -0,0 +1,9 @@
{
"runtime": {
"version": "LuaJIT",
"pathStrict": true
},
"type": {
"checkTableShape": true
}
}

View file

@ -34,6 +34,9 @@ local function read_link_data(path, cb)
)
end
---@class (exact) oil.FilesAdapter: oil.Adapter
---@field to_short_os_path fun(path: string, entry_type: nil|oil.EntryType): string
---@param path string
---@param entry_type nil|oil.EntryType
---@return string
@ -284,6 +287,7 @@ end
---@param column_defs string[]
---@param cb fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())
local function list_windows_drives(url, column_defs, cb)
---@cast M oil.FilesAdapter
local fetch_meta = columns.get_metadata_fetcher(M, column_defs)
local stdout = ""
local jid = vim.fn.jobstart({ "wmic", "logicaldisk", "get", "name" }, {
@ -341,6 +345,7 @@ M.list = function(url, column_defs, cb)
return list_windows_drives(url, column_defs, cb)
end
local dir = fs.posix_to_os_path(path)
---@cast M oil.Adapter
local fetch_meta = columns.get_metadata_fetcher(M, column_defs)
---@diagnostic disable-next-line: param-type-mismatch, discard-returns

View file

@ -50,6 +50,7 @@ M.parse_url = function(oil_url)
error(string.format("Malformed SSH url: %s", oil_url))
end
---@cast ret oil.sshUrl
return ret
end
@ -440,6 +441,7 @@ M.goto_file = function()
url.path = vim.fs.dirname(fullpath)
local parurl = url_to_str(url)
---@cast M oil.Adapter
util.adapter_list_all(M, parurl, {}, function(err, entries)
if err then
vim.notify(string.format("Error finding file '%s': %s", fname, err), vim.log.levels.ERROR)

View file

@ -176,6 +176,7 @@ function SSHConnection.new(url)
end
end)
---@cast self oil.sshConnection
return self
end

View file

@ -70,6 +70,7 @@ end
---@param url oil.sshUrl
---@return oil.sshFs
function SSHFS.new(url)
---@type oil.sshFs
return setmetatable({
conn = SSHConnection.new(url),
}, {

View file

@ -210,6 +210,7 @@ local function read_trash_info(info_file, cb)
cb(".trashinfo file points to non-existant file")
else
trash_info.stat = trash_stat
---@cast trash_info oil.TrashInfo
cb(nil, trash_info)
end
end)

View file

@ -22,6 +22,7 @@ function PowershellConnection.new(init_command)
self:_init(init_command)
---@type oil.PowershellConnection
return self
end

View file

@ -98,7 +98,7 @@ M.calculate_height = function(desired_height, opts)
)
end
---@class (exact) conform.WinLayout
---@class (exact) oil.WinLayout
---@field width integer
---@field height integer
---@field row integer
@ -139,14 +139,15 @@ end
---@param winid integer
---@param direction "above"|"below"|"left"|"right"|"auto"
---@param gap integer
---@return conform.WinLayout root_dim New dimensions of the original window
---@return conform.WinLayout new_dim New dimensions of the new window
---@return oil.WinLayout root_dim New dimensions of the original window
---@return oil.WinLayout new_dim New dimensions of the new window
M.split_window = function(winid, direction, gap)
if direction == "auto" then
direction = vim.o.splitright and "right" or "left"
end
local float_config = vim.api.nvim_win_get_config(winid)
---@type oil.WinLayout
local dim_root = {
width = float_config.width,
height = float_config.height,

View file

@ -7,6 +7,7 @@ local Trie = {}
---@return oil.Trie
Trie.new = function()
---@type oil.Trie
return setmetatable({
root = { values = {}, children = {} },
}, {