Files
nvim-tree.lua/lua/nvim-tree/core.lua
Kiyan b0d27c09b6 feat(explorer): add filesystem watchers (#1304)
* feat(explorer): add experimental watchers

This commit introduces watchers to update the tree.
This behavior is introduced behind an "filesystem_watchers" option
which should prevent instabilities.
It will become the default at some point.

Co-authored-by: Alexander Courtis <alex@courtis.org>
2022-06-05 12:39:39 +02:00

42 lines
822 B
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 M = {}
TreeExplorer = nil
local first_init_done = false
function M.init(foldername)
if TreeExplorer then
TreeExplorer:_clear_watchers()
end
TreeExplorer = explorer.Explorer.new(foldername)
if not first_init_done then
events._dispatch_ready()
first_init_done = true
end
end
function M.get_explorer()
return TreeExplorer
end
function M.get_cwd()
return TreeExplorer.absolute_path
end
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