From e9fdae57a788677d5ec4a70b701d64b351588930 Mon Sep 17 00:00:00 2001 From: olimorris Date: Thu, 23 Feb 2023 11:13:55 +0000 Subject: [PATCH] docs: document data available in the callbacks --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1de512d..d573806 100644 --- a/README.md +++ b/README.md @@ -296,9 +296,11 @@ vim.api.nvim_create_autocmd({ "User" }, { }) ``` -Session data is also made available to the callback: +Session data is also made available to the callbacks: ```lua +local group = vim.api.nvim_create_augroup("PersistedHooks", {}) + vim.api.nvim_create_autocmd({ "User" }, { pattern = "PersistedTelescopeLoadPre", group = group, @@ -308,6 +310,8 @@ vim.api.nvim_create_autocmd({ "User" }, { }) ``` +The session data available differs depending on the events that are hooked into. For non-telescope events, only the session `name` is available (via `session.data.name`). However for telescope events, the `branch`, `name`, `file_path` and `dir_path` are available. + Finaly, if you're using the excellent [Legendary.nvim](https://github.com/mrjones2014/legendary.nvim) plugin, consider the following snippet format: ```lua