Created
December 24, 2021 07:54
-
-
Save LinArcX/1d46cf87a0d55f5313060d4581cebb17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function bar(opts) | |
opts = opts or {} | |
pickers.new(opts, { | |
prompt_title = "bar", | |
finder = finders.new_table { | |
results = { ":Telescope grep_string", ":Telescope find_files" , ":Telescope registers"}, | |
}, | |
sorter = conf.generic_sorter(opts), | |
attach_mappings = function(prompt_bufnr, map) | |
actions.select_default:replace(function() | |
actions.close(prompt_bufnr) | |
local selection = action_state.get_selected_entry() | |
print(vim.inspect(selection.value)) | |
vim.api.nvim_exec(selection.value, true) | |
end) | |
return true | |
end, | |
}):find() | |
end | |
local function foo(opts) | |
opts = opts or {} | |
pickers.new(opts, { | |
prompt_title = "foo", | |
finder = finders.new_table { | |
results = { "hi", "bye" , "tye"}, | |
}, | |
sorter = conf.generic_sorter(opts), | |
attach_mappings = function(prompt_bufnr, map) | |
actions.select_default:replace(function() | |
actions.close(prompt_bufnr) | |
local selection = action_state.get_selected_entry() | |
bar(opts) | |
end) | |
return true | |
end, | |
}):find() | |
end | |
foo() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my plugin, I managed to get correct behavior when I wrapped bar in a
vim.schedule()
call: