I am currently trying to write my first plugin. So this is my first attempt at vimscript. I want to display the output of a shell command in a popup window.
This can easily achieved with:
command Cat call CatCurFile()
function! CatCurFile()
let buf = term_start(['cat', @%], #{hidden: 1})
let winid = popup_create(buf, #{minwidth: 120, minheight: 70})
endfunction
The popup window is built up from top to bottom, which is not pretty. I would like the have the whole terminal buffer pre-rendered somehow, so that it instantly displays everything.
cat is just an example here. The actual application is a bit slower unfortunately.
I have tried
command Cat call CatCurFile()
function! CatCurFile()
let buf = term_start(['cat', @%], #{hidden: 1})
let winid = popup_create(buf, #{hidden: 1, minwidth: 120, minheight: 70})
popup_show(winid)
endfunction
but the popup is not showing. Instead an error saying menu not found
is displayed. Is the id not passed right?
:call popup_show(winid)
to call a function (unless you're using vim9script) (the colon is optional in scripts). Also see the"term_finish": "open"
option onterm_start()
term_finish
as open, the window doesn’t even open until the command is finished, so all the output is there.