Skip to content

feat(event): add TreeAttachedPost #1877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,12 @@ e.g. handler for node renamed: >
handler parameters: ~
{folder_name} `{string}` Absolute path to the removed folder.

- Event.TreeAttachedPost
Invoked after the tree's buffer has been created and mappings
have been applied: |nvim-tree-mappings| or |nvim-tree.on_attach|
handler parameters: ~
{buf} `{number} `API buffer handle (buffer number)

==============================================================================
9. BOOKMARKS *nvim-tree-bookmarks*

Expand Down
6 changes: 6 additions & 0 deletions lua/nvim-tree/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ M.Event = {
FolderCreated = "FolderCreated",
FolderRemoved = "FolderRemoved",
Resize = "Resize",
TreeAttachedPost = "TreeAttachedPost",
}

local function get_handlers(event_name)
Expand Down Expand Up @@ -86,6 +87,11 @@ function M._dispatch_on_tree_resize(size)
dispatch(M.Event.Resize, size)
end

--@private
function M._dispatch_tree_attached_post(buf)
dispatch(M.Event.TreeAttachedPost, buf)
end

--- @deprecated
function M.on_nvim_tree_ready(handler)
M.subscribe(M.Event.Ready, handler)
Expand Down
1 change: 1 addition & 0 deletions lua/nvim-tree/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ local function create_buffer(bufnr)
else
require("nvim-tree.actions").apply_mappings(M.get_bufnr())
end
events._dispatch_tree_attached_post(M.get_bufnr())
end

local function get_size()
Expand Down