feat(event): add TreeAttachedPost (#1877)

* feat(event): add OnAttachPost

* feat(event): add TreeAttachPost

* feat(event): add TreeAttachPost

* feat(event): TreeAttachedPost fired after all mappings created, not just on_attach
This commit is contained in:
Alexander Courtis 2023-01-07 11:50:41 +11:00 committed by GitHub
parent bac962caf4
commit f43f3110a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View File

@ -1653,6 +1653,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*

View File

@ -15,6 +15,7 @@ M.Event = {
FolderCreated = "FolderCreated",
FolderRemoved = "FolderRemoved",
Resize = "Resize",
TreeAttachedPost = "TreeAttachedPost",
}
local function get_handlers(event_name)
@ -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)

View File

@ -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()