Skip to content

refactor: register snacks picker as a source #3228

@drowning-cat

Description

@drowning-cat

Did you check docs and existing issues?

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.

See noice/config/init.lua.

Tip

Use the picker’s finder option to populate the items based on the picker.layers option (extend snacks.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: folke/snacks.nvim#2433 (comment)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions