* 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>
55 lines
1.1 KiB
Lua
55 lines
1.1 KiB
Lua
local events = require "nvim-tree.events"
|
|
local explorer = require "nvim-tree.explorer"
|
|
local live_filter = require "nvim-tree.live-filter"
|
|
local view = require "nvim-tree.view"
|
|
local log = require "nvim-tree.log"
|
|
|
|
local M = {}
|
|
|
|
---@type Explorer|nil
|
|
local TreeExplorer = nil
|
|
local first_init_done = false
|
|
|
|
---@param foldername string
|
|
function M.init(foldername)
|
|
local profile = log.profile_start("core init %s", foldername)
|
|
|
|
if TreeExplorer then
|
|
TreeExplorer:destroy()
|
|
end
|
|
TreeExplorer = explorer.Explorer.new(foldername)
|
|
if not first_init_done then
|
|
events._dispatch_ready()
|
|
first_init_done = true
|
|
end
|
|
log.profile_end(profile)
|
|
end
|
|
|
|
---@return Explorer|nil
|
|
function M.get_explorer()
|
|
return TreeExplorer
|
|
end
|
|
|
|
function M.reset_explorer()
|
|
TreeExplorer = nil
|
|
end
|
|
|
|
---@return string|nil
|
|
function M.get_cwd()
|
|
return TreeExplorer and TreeExplorer.absolute_path
|
|
end
|
|
|
|
---@return integer
|
|
function M.get_nodes_starting_line()
|
|
local offset = 1
|
|
if view.is_root_folder_visible(M.get_cwd()) then
|
|
offset = offset + 1
|
|
end
|
|
if live_filter.filter then
|
|
return offset + 1
|
|
end
|
|
return offset
|
|
end
|
|
|
|
return M
|