Skip to content

Commit

Permalink
lint: stricter type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Sep 17, 2024
1 parent f60bb7f commit 1360be5
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"runtime": {
"version": "LuaJIT",
"pathStrict": true
},
"type": {
"checkTableShape": true
}
}
5 changes: 5 additions & 0 deletions lua/oil/adapters/files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" }, {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lua/oil/adapters/ssh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lua/oil/adapters/ssh/connection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function SSHConnection.new(url)
end
end)

---@cast self oil.sshConnection
return self
end

Expand Down
1 change: 1 addition & 0 deletions lua/oil/adapters/ssh/sshfs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}, {
Expand Down
1 change: 1 addition & 0 deletions lua/oil/adapters/trash/freedesktop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lua/oil/adapters/trash/windows/powershell-connection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function PowershellConnection.new(init_command)

self:_init(init_command)

---@type oil.PowershellConnection
return self
end

Expand Down
7 changes: 4 additions & 3 deletions lua/oil/layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lua/oil/mutator/trie.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local Trie = {}

---@return oil.Trie
Trie.new = function()
---@type oil.Trie
return setmetatable({
root = { values = {}, children = {} },
}, {
Expand Down

0 comments on commit 1360be5

Please sign in to comment.