refactor: register `snacks` picker as a source
Did you check docs and existing issues?
- [x] Make sure to search for a solution in old issues before posting a new one.
- [x] Learn at least a minimum of Markdown formatting (https://guides.github.com/features/mastering-markdown).
Is your feature request related to a problem?
[!CAUTION] I don't use this plugin myself.
It’s not possible to reliably extend the plugin’s vimtex.snacks picker (require("vimtex.snacks").toc) because it explicitly defines options that override snacks sources.vimtex_toc configuration. This prevents customization of certain fields, such as layout.preset.
Describe the solution you’d like (good)
Register the picker similarly to how noice.nvim does it — by extending Snacks.picker.sources table instead of passing options directly to Snacks.picker.pick.
[!TIP] Use the picker’s
finderoption to populate the items based on thepicker.layersoption (extendsnacks.picker.Config). See noice/integrations/snacks.lua.
Describe alternatives you’ve considered
A possible workaround is to allow passing a snacks.picker.Config options directly to require("vimtex.snacks").toc(<options>) via an argument:
---@class VimtexSnacksOptions: snacks.picker.Config
---@field layers? string -- The layers to filter, e.g., a substring of "ctli"
--- corresponds to content, todos, labels, and includes.
But I still recommend using the first (good) approach, binding require("vimtex.snacks").toc to Snacks.picker.vimtex_toc.
Additional context
Thanks to @dpetka2001 for identifying the issue and suggesting a solution.
See the original discussion: https://github.com/folke/snacks.nvim/discussions/2433#discussioncomment-14868217