nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
14.76k stars 808 forks source link

vim.fn.input to vim.ui.input #1479

Open IndianBoy42 opened 2 years ago

IndianBoy42 commented 2 years ago

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

vim.ui.input was merged a few weeks ago and is user overridable to provide a nicer and customizable input interface. it isn't trivial to switch as vim.ui.input uses a callback instead of blocking and returning the result. However within a plenary async loop it becomes trivial again using require("plenary.async").wrap

This is enough to create a function that (within async context) acts similar to vim.fn.input

local async = require("plenary.async")
-- local input = vim.fn.input
local input = async.wrap(function(prompt, text, completion, callback)
    vim.ui.input({
        prompt = prompt,
        default = text,
        completion = completion,
    }, callback)
end, 4)

Otherwise a little bit of refactoring probably lets use use vim.ui.input for any pickers that need it

Describe alternatives you've considered Since the plan is to move the pickers out of telescope.nvim, I don't know if you want this PR now, but I'm happy to do the work. It should be confined to just that one file

Additional context

https://github.com/neovim/neovim/pull/15959

fdschmidt93 commented 2 years ago

cc @p00f -- I think this might be of interest for you.

p00f commented 2 years ago

Thanks for the ping!