Open Gazareth opened 8 months ago
A better name for this might be 'extensions', similar to telescope.
Now I also think that wasn't the best decision as it is a bit confusing, but I think it's too late for it to be worth changing, so let's just stick with "plugins".
Regarding your main question - do you want to add something generic to possession.nvim itself or rather something custom for your nvim config?
If it's the second one, then you can just use the user hooks (require('possession').setup { hooks = { before_save = function ... } }
). Otherwise, you just add a file possession.nvim/lua/possession/plugins/myplugin.lua
and add it's name ('myplugin',
) to plugins array and add it's configuration to config.lua. You can take a look at commits that add other plugins, e.g. https://github.com/jedrzejboczar/possession.nvim/commit/4665ceec10991e040b7117582e62cc5edd3c964f, or specifically related to storing tab names: https://github.com/jedrzejboczar/possession.nvim/commit/acc5e8e5cbdb1a060f9fa8291166b7b52ee4ce77.
I was just wondering if it's possible to create plugins that are distributed externally to this repo.
I am happy to use user hooks for now, but if I wanted to distribute my plugin to other people who use possession.nvim, without merging a PR into the main repo (since it might be something really niche, that doesn't need to be part of the canonical possession distribution)
Ok, now I understand. Currently it's not possible, but I guess it could be nice to have such option.
So my initial idea would be as follows:
my_plugin
and create my_plugin/lua/possession/plugins/my_plugin.lua
possession.setup { plugins = { my_plugin = true --[[ or table of settings ]] } }
plugins
table and allow plugins to return their priorities? Not sure about this oneWhat do you think?
Your idea would work for minimal changes to posession, however I think ultimately it'd be better to have something more akin to telescope's plugin model, where the consumer uses this syntax, e.g.
require('telescope').load_extension('my-plugin')
Since it's more generic, doesn't require knowledge of the architecture within, e.g. plugin ordering, table structure to pass in, etc.
I'd like to add my own plugin that uses the hooks and adds its own
plugin_data
to the session.For example if you wanted to give open tabs custom names, and store them in the session JSON file.
I've looked through the code and I can't see any way to add to the
plugins
array?A better name for this might be 'extensions', similar to telescope.