aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-06-05 08:25:53 -0300
committerJustin M. Keyes <justinkz@gmail.com>2014-10-28 23:12:41 -0400
commit94f59fc9be03cf0ee3ac20f2715738f017439502 (patch)
treec53a9e96293d7294ada34636eb26eb7a99bdb0fd /src/nvim/api/vim.c
parentc28adf15e6c2079c732bb77fb99c50b80a4d7fe2 (diff)
downloadrneovim-94f59fc9be03cf0ee3ac20f2715738f017439502.tar.gz
rneovim-94f59fc9be03cf0ee3ac20f2715738f017439502.tar.bz2
rneovim-94f59fc9be03cf0ee3ac20f2715738f017439502.zip
api: Implement vim_command_output function
This function can be used by API clients to execute a command and capture the output.
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index c90e7039ce..9afefd6fa3 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -96,6 +96,19 @@ String vim_replace_termcodes(String str, Boolean from_part, Boolean do_lt,
return cstr_as_string(ptr);
}
+String vim_command_output(String str, Error *err)
+{
+ do_cmdline_cmd((char_u *)"redir => v:command_output");
+ vim_command(str, err);
+ do_cmdline_cmd((char_u *)"redir END");
+
+ if (err->set) {
+ return (String) STRING_INIT;
+ }
+
+ return cstr_to_string((char *)get_vim_var_str(VV_COMMAND_OUTPUT));
+}
+
/// Evaluates the expression str using the vim internal expression
/// evaluator (see |expression|).
/// Dictionaries and lists are recursively expanded.