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:
Sebastian Lyng Johansen
2021-11-07 16:13:53 +01:00
committed by GitHub
parent b74916cfd2
commit 16d4af6d2f
6 changed files with 106 additions and 13 deletions

View File

@@ -2435,9 +2435,9 @@ describe('LSP', function()
local bufnr = vim.api.nvim_get_current_buf()
lsp.buf_attach_client(bufnr, TEST_RPC_CLIENT_ID)
vim.lsp._stubs = {}
vim.fn.input = function(prompt, text)
vim.lsp._stubs.input_prompt = prompt
vim.lsp._stubs.input_text = text
vim.fn.input = function(opts, on_confirm)
vim.lsp._stubs.input_prompt = opts.prompt
vim.lsp._stubs.input_text = opts.default
return 'renameto' -- expect this value in fake lsp
end
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {'', 'this is line two'})