How to dump output of command in neovim?

:vnew +pu=execute(' ')

I know this command to dump output but I don’t know how to use it with CocCommand

I try this but it didn’t work

:vnew +pu=execute(' CocCommand rust-analyzer.serverVersion ')

1 Like

Not quite what you’re looking for, but you can look at the redir command to dump output into a register, then paste it wherever you want.

it’s possible to write a small Lua function which calls and captures some command’s output into a local variable and pastes that variable to a buffer or float. I’ve actually written one for Rust’s Cargo’s search command. Check out rust.vim/cargo.vim at master · rust-lang/rust.vim · GitHub for an example in vimscript, although, I can assure, writing something alike in Lua is much easier. Neovim helpfully provides an api function for creating commands in Lua, so you can just shove your function inside it and reuse it anytime