nvim-tree.lua/lua/nvim-tree/core.lua
Alexander Courtis 1ae1c33ce1
chore(#2931): stylua -> EmmyLuaCodeStyle (#2932)
* stylua -> EmmyLuaCodeStyle: config and doc

* stylua -> EmmyLuaCodeStyle: CI

* stylua -> EmmyLuaCodeStyle: CI

* stylua -> EmmyLuaCodeStyle: CI

* stylua -> EmmyLuaCodeStyle: CI

* stylua -> EmmyLuaCodeStyle: CI

* stylua -> EmmyLuaCodeStyle

* stylua -> EmmyLuaCodeStyle: call_arg_parentheses = always

* stylua -> EmmyLuaCodeStyle

* stylua -> EmmyLuaCodeStyle
2024-09-29 14:05:52 +10:00

53 lines
1.1 KiB
Lua

local events = require("nvim-tree.events")
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 = require("nvim-tree.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 TreeExplorer and TreeExplorer.live_filter.filter then
return offset + 1
end
return offset
end
return M