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:
@@ -9,7 +9,7 @@ local M = {
|
||||
}
|
||||
|
||||
--- Delete nodes; each removal will be optionally notified
|
||||
--- @param nodes table
|
||||
---@param nodes Node[]
|
||||
local function do_delete(nodes)
|
||||
for _, node in pairs(nodes) do
|
||||
remove_file.remove(node)
|
||||
|
||||
@@ -9,7 +9,7 @@ local M = {
|
||||
}
|
||||
|
||||
--- Delete nodes; each removal will be optionally notified
|
||||
--- @param nodes table
|
||||
---@param nodes Node[]
|
||||
local function do_trash(nodes)
|
||||
for _, node in pairs(nodes) do
|
||||
remove_file.remove(node)
|
||||
|
||||
@@ -4,18 +4,24 @@ local NvimTreeMarks = {}
|
||||
|
||||
local M = {}
|
||||
|
||||
---@class MinimalNode
|
||||
---@field absolute_path string
|
||||
|
||||
---@param node Node|MinimalNode
|
||||
local function add_mark(node)
|
||||
NvimTreeMarks[node.absolute_path] = node
|
||||
|
||||
renderer.draw()
|
||||
end
|
||||
|
||||
---@param node Node|MinimalNode
|
||||
local function remove_mark(node)
|
||||
NvimTreeMarks[node.absolute_path] = nil
|
||||
|
||||
renderer.draw()
|
||||
end
|
||||
|
||||
---@param node Node|MinimalNode
|
||||
function M.toggle_mark(node)
|
||||
if node.absolute_path == nil then
|
||||
return
|
||||
@@ -36,10 +42,13 @@ function M.clear_marks()
|
||||
renderer.draw()
|
||||
end
|
||||
|
||||
---@param node Node|MinimalNode
|
||||
---@return table|nil
|
||||
function M.get_mark(node)
|
||||
return NvimTreeMarks[node.absolute_path]
|
||||
end
|
||||
|
||||
---@return table
|
||||
function M.get_marks()
|
||||
local list = {}
|
||||
for _, node in pairs(NvimTreeMarks) do
|
||||
|
||||
@@ -5,6 +5,9 @@ local open_file = require "nvim-tree.actions.node.open-file"
|
||||
local utils = require "nvim-tree.utils"
|
||||
local lib = require "nvim-tree.lib"
|
||||
|
||||
---@param node table
|
||||
---@param where string
|
||||
---@return Node|nil
|
||||
local function get_nearest(node, where)
|
||||
local first, prev, next, last = nil, nil, nil, nil
|
||||
local found = false
|
||||
@@ -47,12 +50,16 @@ local function get_nearest(node, where)
|
||||
end
|
||||
end
|
||||
|
||||
---@param where string
|
||||
---@param node table|nil
|
||||
---@return Node|nil
|
||||
local function get(where, node)
|
||||
if node then
|
||||
return get_nearest(node, where)
|
||||
end
|
||||
end
|
||||
|
||||
---@param node table|nil
|
||||
local function open_or_focus(node)
|
||||
if node and not node.nodes and not utils.get_win_buf_from_path(node.absolute_path) then
|
||||
open_file.fn("edit", node.absolute_path)
|
||||
@@ -61,6 +68,8 @@ local function open_or_focus(node)
|
||||
end
|
||||
end
|
||||
|
||||
---@param where string
|
||||
---@return function
|
||||
local function navigate_to(where)
|
||||
return function()
|
||||
local node = lib.get_node_at_cursor()
|
||||
|
||||
Reference in New Issue
Block a user