diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-01-18 00:37:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-18 09:37:18 +0100 |
commit | 61437c20b5936de1f833d155b7287d9151e763d8 (patch) | |
tree | 86afea1d746f2d1d8e00ab4cb45370f21228871e /src/nvim/lua/executor.c | |
parent | 702208daa6553ecfc3939c3c6e9fcd94fdd5aeba (diff) | |
download | rneovim-61437c20b5936de1f833d155b7287d9151e763d8.tar.gz rneovim-61437c20b5936de1f833d155b7287d9151e763d8.tar.bz2 rneovim-61437c20b5936de1f833d155b7287d9151e763d8.zip |
api: add vim.version (#13762)
retrun a structured version dict
:lua print(vim.inspect(vim.version()))
{
api_compatible = 0,
api_level = 7,
api_prerelease = true,
major = 0,
minor = 5,
patch = 0
}
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r-- | src/nvim/lua/executor.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 344a2387d6..3219c02068 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -5,6 +5,7 @@ #include <lualib.h> #include <lauxlib.h> +#include "nvim/version.h" #include "nvim/misc1.h" #include "nvim/getchar.h" #include "nvim/garray.h" @@ -78,6 +79,17 @@ static void nlua_error(lua_State *const lstate, const char *const msg) lua_pop(lstate, 1); } +/// Return version of current neovim build +/// +/// @param lstate Lua interpreter state. +static int nlua_nvim_version(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL +{ + Dictionary version = version_dict(); + nlua_push_Dictionary(lstate, version, true); + api_free_dictionary(version); + return 1; +} + /// Compare two strings, ignoring case /// /// Expects two values on the stack: compared strings. Returns one of the @@ -420,6 +432,9 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL // str_byteindex lua_pushcfunction(lstate, &nlua_str_byteindex); lua_setfield(lstate, -2, "str_byteindex"); + // neovim version + lua_pushcfunction(lstate, &nlua_nvim_version); + lua_setfield(lstate, -2, "version"); // schedule lua_pushcfunction(lstate, &nlua_schedule); lua_setfield(lstate, -2, "schedule"); |