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

@@ -3,8 +3,8 @@ local M = {}
local C = {}
--- Predefined comparator, defaulting to name
--- @param sorter string as per options
--- @return function
---@param sorter string as per options
---@return function
local function get_comparator(sorter)
return C[sorter] or C.name
end
@@ -24,8 +24,8 @@ local function tbl_slice(t, first, last)
end
---Evaluate `sort.folders_first` and `sort.files_first`
---@param a table node
---@param b table node
---@param a Node
---@param b Node
---@return boolean|nil
local function folders_or_files_first(a, b)
if not (M.config.sort.folders_first or M.config.sort.files_first) then
@@ -41,6 +41,11 @@ local function folders_or_files_first(a, b)
end
end
---@param t table
---@param first number
---@param mid number
---@param last number
---@param comparator fun(a: Node, b: Node): boolean
local function merge(t, first, mid, last, comparator)
local n1 = mid - first + 1
local n2 = last - mid
@@ -74,6 +79,10 @@ local function merge(t, first, mid, last, comparator)
end
end
---@param t table
---@param first number
---@param last number
---@param comparator fun(a: Node, b: Node): boolean
local function split_merge(t, first, last, comparator)
if (last - first) < 1 then
return
@@ -137,6 +146,10 @@ function M.sort(t)
end
end
---@param a Node
---@param b Node
---@param ignorecase boolean|nil
---@return boolean
local function node_comparator_name_ignorecase_or_not(a, b, ignorecase)
if not (a and b) then
return true