diff options
| author | Shadman <shadmansaleh3@gmail.com> | 2026-03-27 17:39:09 +0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-27 07:39:09 -0400 |
| commit | a940b77cb25ae12cc1269cf64bdede698a4c5aac (patch) | |
| tree | 4106d8538e2b5ac566475b5469b202507627258a /runtime/lua/vim/_meta/vimfn.lua | |
| parent | 0fa96585dc1deda5bdba4053a51cafee6308c095 (diff) | |
| download | rneovim-a940b77cb25ae12cc1269cf64bdede698a4c5aac.tar.gz rneovim-a940b77cb25ae12cc1269cf64bdede698a4c5aac.tar.bz2 rneovim-a940b77cb25ae12cc1269cf64bdede698a4c5aac.zip | |
feat(prompt): prompt_appendbuf() appends to prompt buffer #37763
Problem:
Currently, we recommend always inserting text above prompt-line in
prompt-buffer. This can be done using the `:` mark. However, although
we recommend it this way it can sometimes get confusing how to do it
best.
Solution:
Provide an api to append text to prompt buffer. This is a common
use-case for things using prompt-buffer.
Diffstat (limited to 'runtime/lua/vim/_meta/vimfn.lua')
| -rw-r--r-- | runtime/lua/vim/_meta/vimfn.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 1d3412d20a..a5822c9c84 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -6893,6 +6893,28 @@ function vim.fn.prevnonblank(lnum) end --- @return string function vim.fn.printf(fmt, expr1) end +--- Appends text to prompt buffer before current prompt. When {text} is +--- a |List|: Append each item of the |List| as a text line above +--- prompt-line in the buffer. Any type of item is accepted and converted +--- to a String. Returns 1 for failure ({buf} not a prmopt buffer), +--- 0 for success. When {text} is an empty list zero is returned. +--- +--- Example: >vim +--- func TextEntered(text) +--- call prompt_appendbuf(bufnr(''), split('Entered: "' . a:text . '"', '\n')) +--- endfunc +--- +--- set buftype=prompt +--- call prompt_setcallback(bufnr(''), function("TextEntered")) +--- eval bufnr("")->prompt_setprompt("cmd: ") +--- startinsert +--- < +--- +--- @param buf integer|string +--- @param text string|string[] +--- @return 0|1 +function vim.fn.prompt_appendbuf(buf, text) end + --- Gets the current user-input in |prompt-buffer| {buf} without invoking --- prompt_callback. {buf} can be a buffer name or number. --- |