Merge branch 'master' into type-annotations
This commit is contained in:
@@ -14,7 +14,7 @@ local M = {}
|
||||
local function refresh_nodes(node, projects, unloaded_bufnr)
|
||||
Iterator.builder({ node })
|
||||
:applier(function(n)
|
||||
if n.open and n.nodes then
|
||||
if n.nodes then
|
||||
local toplevel = git.get_toplevel(n.cwd or n.link_to or n.absolute_path)
|
||||
explorer_module.reload(n, projects[toplevel] or {}, unloaded_bufnr)
|
||||
end
|
||||
|
||||
@@ -146,6 +146,11 @@ Api.tree.is_tree_buf = wrap(require("nvim-tree.utils").is_nvim_tree_buf)
|
||||
|
||||
Api.tree.is_visible = wrap(require("nvim-tree.view").is_visible)
|
||||
|
||||
---@class ApiTreeWinIdOpts
|
||||
---@field tabpage number|nil default nil
|
||||
|
||||
Api.tree.winid = wrap(require("nvim-tree.view").winid)
|
||||
|
||||
Api.fs.create = wrap_node_or_nil(require("nvim-tree.actions.fs.create-file").fn)
|
||||
Api.fs.remove = wrap_node(require("nvim-tree.actions.fs.remove-file").fn)
|
||||
Api.fs.trash = wrap_node(require("nvim-tree.actions.fs.trash").fn)
|
||||
|
||||
@@ -433,6 +433,21 @@ function M.focus(winnr, open_if_closed)
|
||||
vim.api.nvim_set_current_win(wnr)
|
||||
end
|
||||
|
||||
--- Retrieve the winid of the open tree.
|
||||
--- @param opts ApiTreeWinIdOpts|nil
|
||||
--- @return number|nil winid unlike get_winnr(), this returns nil if the nvim-tree window is not visible
|
||||
function M.winid(opts)
|
||||
local tabpage = opts and opts.tabpage
|
||||
if tabpage == 0 then
|
||||
tabpage = vim.api.nvim_get_current_tabpage()
|
||||
end
|
||||
if M.is_visible { tabpage = tabpage } then
|
||||
return M.get_winnr(tabpage)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
--- Restores the state of a NvimTree window if it was initialized before.
|
||||
function M.restore_tab_state()
|
||||
local tabpage = vim.api.nvim_get_current_tabpage()
|
||||
|
||||
Reference in New Issue
Block a user