Open tex opened 4 months ago
@tex I provided a comment on this reddit post where I explain how you can achieve this now:
https://www.reddit.com/r/neovim/comments/1d77kok/comment/l6zd5l7/
local snap = require("snap")
local tbl = require("snap.common.tbl")
-- Here we are storing the old version of snap.run
local run = snap.run
-- Here we will store each config that is passed to snap.run
local last_config = nil
-- Here we are overriding snap.run, this isn't the most sane thing to do but it will work
snap.run = function(config)
last_config = config
local function on_update(filter)
if config.on_update then
config.on_update(filter)
end
last_config.initial_filter = filter
end
run(tbl.merge(config, { on_update = on_update }))
end
-- Now all usages of snap.run use the above definition and have their config stored,
-- whether they are generated from snap.config, or just plain invocations of snap.run
-- So you can now do all your setups as normal, but you can additionally now register a "last search" style setup
snap.maps({
{
"<Leader>i",
function ()
if last_config then
snap.run(last_config)
end
end
}
})
Nice, thanks! I saw that reddit article but did not notice he is also using Snap :) Integrating seems like a nice approach. BTW I am working on tags support (gtags/global).
Regarding the resuming previous dialog, it is not only about remembering the filter. But also position in the list of results. Ideally it should remember the results and not run producer again when resumed.
Inlcuding previous initial_filter and position of cursor in search result.