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

@@ -1,6 +1,9 @@
---@class NodeIterator
local NodeIterator = {}
NodeIterator.__index = NodeIterator
---@param nodes Node[]
---@return NodeIterator
function NodeIterator.builder(nodes)
return setmetatable({
nodes = nodes,
@@ -15,6 +18,7 @@ function NodeIterator.builder(nodes)
}, NodeIterator)
end
---@return NodeIterator
function NodeIterator:hidden()
self._filter_hidden = function(_)
return true
@@ -22,21 +26,29 @@ function NodeIterator:hidden()
return self
end
---@param f fun(node: Node): boolean
---@return NodeIterator
function NodeIterator:matcher(f)
self._match = f
return self
end
---@param f fun(node: Node, i: number)
---@return NodeIterator
function NodeIterator:applier(f)
self._apply_fn_on_node = f
return self
end
---@param f fun(node: Node): any
---@return NodeIterator
function NodeIterator:recursor(f)
self._recurse_with = f
return self
end
---@return Node|nil
---@return number|nil
function NodeIterator:iterate()
local iteration_count = 0
local function iter(nodes)