camspiers / snap

A fast finder system for neovim.
The Unlicense
483 stars 16 forks source link

How to pass initial filter? #90

Closed tex closed 4 months ago

tex commented 4 months ago

How to pass initial filter to snap.run? Idea is I am under a word I want to grep to just press keybinding to initiate search and then refine it later in snap ui.

tex commented 4 months ago

I found your nvim config and learned about { filter_with = "cword" }. Awesome project. Trying to migrate to Snap from Telescope.

tex commented 4 months ago

Well, I know this works for snap.config things. How to make it work for custom producer like this one?

snap.register.map({"n"}, {"<Leader>ft"}, function ()
  snap.run {
    producer = consumer(producer),
    select = print,
    prompt = "Hello >",
  }
end)

consumer, producer are same as in ls example in the Readme.

tex commented 4 months ago

This does it:

snap.register.map({"n"}, {"<Leader>ft"}, function ()
  snap.run {
    producer = consumer(producer),
    select = print,
    prompt = "Hello >",
    initial_filter = "filter",
  }
end)

cword / selection needs to be done manually.