chore: add type annotations and resolve LSP warnings (#2555)

* chore: add type annotations to (almost) all functions

* stylua

* Add classes for symlink nodes

* Replace deprecated `@vararg`

* Move node classes to `node` module

* Fix `Symlink*` classes

* add vim and libuv runtime for luals, qualify libuv types

* add scripts/luals-check, not quite ready for CI

* additional nil checks for git/init.lua and git/runner.lua

* additional nil checks for nvim-tree.lua

* wrap vim.cmd-as-a-function calls inside functions

* vim.tbl_filter predicate returns booleans

* Revert "add scripts/luals-check, not quite ready for CI"

This reverts commit c70229cad9.

* Add `MinimalNode` class in `marks` module

* Fix various LSP warnings

* stylua

* Fix `Explorer` class, update related annotations and add necessary checks

* Add missing annotations to `live-filter`

* Add temporary aliases for `uv.*` types

* Resolve remaining LSP warnings

* Revert changes not related to internal types

* Minor adjustments

* Update doc comments style

* Minor adjustments (pt. 2)

---------

Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
Azad
2023-12-09 01:34:35 +01:00
committed by GitHub
parent 7d1760f892
commit 13f967f8e7
51 changed files with 622 additions and 161 deletions

View File

@@ -4,9 +4,9 @@ local M = {
}
--- Write to log file
--- @param typ string as per log.types config
--- @param fmt string for string.format
--- @vararg any arguments for string.format
---@param typ string as per log.types config
---@param fmt string for string.format
---@param ... any arguments for string.format
function M.raw(typ, fmt, ...)
if not M.enabled(typ) then
return
@@ -27,9 +27,9 @@ end
--- Write profile start to log file
--- START is prefixed
--- @param fmt string for string.format
--- @vararg any arguments for string.format
--- @return Profile to pass to profile_end
---@param fmt string for string.format
---@param ... any arguments for string.format
---@return Profile to pass to profile_end
function M.profile_start(fmt, ...)
local profile = {}
if M.enabled "profile" then
@@ -42,7 +42,7 @@ end
--- Write profile end to log file
--- END is prefixed and duration in seconds is suffixed
--- @param profile Profile returned from profile_start
---@param profile Profile returned from profile_start
function M.profile_end(profile)
if M.enabled "profile" and type(profile) == "table" then
local millis = profile.start and math.modf((vim.loop.hrtime() - profile.start) / 1000000) or -1
@@ -52,9 +52,9 @@ end
--- Write to log file
--- time and typ are prefixed and a trailing newline is added
--- @param typ string as per log.types config
--- @param fmt string for string.format
--- @vararg any arguments for string.format
---@param typ string as per log.types config
---@param fmt string for string.format
---@param ... any arguments for string.format
function M.line(typ, fmt, ...)
if M.enabled(typ) then
M.raw(typ, string.format("[%s] [%s] %s\n", os.date "%Y-%m-%d %H:%M:%S", typ, (fmt or "???")), ...)
@@ -63,17 +63,17 @@ end
local inspect_opts = {}
--- @param opts table
---@param opts table
function M.set_inspect_opts(opts)
inspect_opts = opts
end
--- Write to log file the inspection of a node
--- defaults to the node under cursor if none is provided
--- @param typ string as per log.types config
--- @param node table|nil node to be inspected
--- @param fmt string for string.format
--- @vararg any arguments for string.format
---@param typ string as per log.types config
---@param node table|nil node to be inspected
---@param fmt string for string.format
---@vararg any arguments for string.format
function M.node(typ, node, fmt, ...)
if M.enabled(typ) then
node = node or require("nvim-tree.lib").get_node_at_cursor()
@@ -82,8 +82,8 @@ function M.node(typ, node, fmt, ...)
end
--- Logging is enabled for typ or all
--- @param typ string as per log.types config
--- @return boolean
---@param typ string as per log.types config
---@return boolean
function M.enabled(typ)
return M.path ~= nil and (M.config.types[typ] or M.config.types.all)
end