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 1 commit
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
Prev Previous commit
feat(event): TreeAttachedPost fired after all mappings created, not j…
…ust on_attach
  • Loading branch information
alex-courtis committed Jan 2, 2023
commit 35f200e3062adeb14012eb9c0fc904e7758bea05
3 changes: 2 additions & 1 deletion doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,8 @@ e.g. handler for node renamed: >
{folder_name} `{string}` Absolute path to the removed folder.

- Event.TreeAttachedPost
Invoked after |nvim-tree.on_attach| has been called.
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)

Expand Down
2 changes: 1 addition & 1 deletion lua/nvim-tree/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function M._dispatch_on_tree_resize(size)
end

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

Expand Down
2 changes: 1 addition & 1 deletion lua/nvim-tree/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ local function create_buffer(bufnr)
if type(M.on_attach) == "function" then
require("nvim-tree.keymap").set_keymaps(M.get_bufnr())
M.on_attach(M.get_bufnr())
events._dispatch_tree_attach_post(M.get_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