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:
@@ -7,11 +7,20 @@ local M = {}
|
||||
M.explore = require("nvim-tree.explorer.explore").explore
|
||||
M.reload = require("nvim-tree.explorer.reload").reload
|
||||
|
||||
---@class Explorer
|
||||
---@field absolute_path string
|
||||
---@field nodes Node[]
|
||||
---@field open boolean
|
||||
|
||||
local Explorer = {}
|
||||
Explorer.__index = Explorer
|
||||
|
||||
---@param cwd string|nil
|
||||
---@return Explorer
|
||||
function Explorer.new(cwd)
|
||||
cwd = vim.loop.fs_realpath(cwd or vim.loop.cwd())
|
||||
|
||||
---@class Explorer
|
||||
local explorer = setmetatable({
|
||||
absolute_path = cwd,
|
||||
nodes = {},
|
||||
@@ -22,12 +31,15 @@ function Explorer.new(cwd)
|
||||
return explorer
|
||||
end
|
||||
|
||||
---@private
|
||||
---@param node Node
|
||||
function Explorer:_load(node)
|
||||
local cwd = node.link_to or node.absolute_path
|
||||
local git_status = git.load_project_status(cwd)
|
||||
M.explore(node, git_status)
|
||||
end
|
||||
|
||||
---@param node Node
|
||||
function Explorer:expand(node)
|
||||
self:_load(node)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user