mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
feat(ui): add vim.ui.input and use in lsp rename (#15959)
* vim.ui.input is an overridable function that prompts for user input * take an opts table and the `on_confirm` callback, see `:help vim.ui.input` for more details * defaults to a wrapper around vim.fn.input(opts) * switches the built-in client's rename handler to use vim.ui.input by default
This commit is contained in:

committed by
GitHub

parent
b74916cfd2
commit
16d4af6d2f
@@ -43,4 +43,29 @@ describe('vim.ui', function()
|
||||
}, result[2])
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('input', function()
|
||||
it('can input text', function()
|
||||
local result = exec_lua[[
|
||||
local opts = {
|
||||
prompt = 'Input: ',
|
||||
}
|
||||
local input
|
||||
local cb = function(item)
|
||||
input = item
|
||||
end
|
||||
-- input would require input and block the test;
|
||||
local prompt
|
||||
vim.fn.input = function(opts)
|
||||
prompt = opts.prompt
|
||||
return "Inputted text"
|
||||
end
|
||||
vim.ui.input(opts, cb)
|
||||
vim.wait(100, function() return input ~= nil end)
|
||||
return {input, prompt}
|
||||
]]
|
||||
eq('Inputted text', result[1])
|
||||
eq('Input: ', result[2])
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user