aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 5b59ff39f4..86e243c4f0 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -955,6 +955,25 @@ void nvim_set_current_win(Window window, Error *err)
}
}
+/// Create new empty buffer
+///
+/// @param listed whether the buffer should be listed
+/// @param[out] err Error details, if any
+/// @return the buffer handle or 0 when error
+Buffer nvim_create_buf(Boolean listed, Error *err)
+ FUNC_API_SINCE(6)
+{
+ try_start();
+ Buffer buffer = buflist_add(NULL,
+ BLN_NOOPT | BLN_NEW | (listed ? BLN_LISTED : 0));
+ if (!try_end(err) && buffer == 0) {
+ api_set_error(err,
+ kErrorTypeException,
+ "Failed to create buffer");
+ }
+ return buffer;
+}
+
/// Gets the current list of tabpage handles.
///
/// @return List of tabpage handles