mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
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 }
This commit is contained in:

committed by
GitHub

parent
702208daa6
commit
61437c20b5
@@ -622,6 +622,9 @@ vim.api.{func}({...}) *vim.api*
|
|||||||
Example: call the "nvim_get_current_line()" API function: >
|
Example: call the "nvim_get_current_line()" API function: >
|
||||||
print(tostring(vim.api.nvim_get_current_line()))
|
print(tostring(vim.api.nvim_get_current_line()))
|
||||||
|
|
||||||
|
vim.version() *vim.version*
|
||||||
|
Returns the version of the current neovim build.
|
||||||
|
|
||||||
vim.in_fast_event() *vim.in_fast_event()*
|
vim.in_fast_event() *vim.in_fast_event()*
|
||||||
Returns true if the code is executing as part of a "fast" event
|
Returns true if the code is executing as part of a "fast" event
|
||||||
handler, where most of the API is disabled. These are low-level events
|
handler, where most of the API is disabled. These are low-level events
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
|
|
||||||
|
#include "nvim/version.h"
|
||||||
#include "nvim/misc1.h"
|
#include "nvim/misc1.h"
|
||||||
#include "nvim/getchar.h"
|
#include "nvim/getchar.h"
|
||||||
#include "nvim/garray.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);
|
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
|
/// Compare two strings, ignoring case
|
||||||
///
|
///
|
||||||
/// Expects two values on the stack: compared strings. Returns one of the
|
/// 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
|
// str_byteindex
|
||||||
lua_pushcfunction(lstate, &nlua_str_byteindex);
|
lua_pushcfunction(lstate, &nlua_str_byteindex);
|
||||||
lua_setfield(lstate, -2, "str_byteindex");
|
lua_setfield(lstate, -2, "str_byteindex");
|
||||||
|
// neovim version
|
||||||
|
lua_pushcfunction(lstate, &nlua_nvim_version);
|
||||||
|
lua_setfield(lstate, -2, "version");
|
||||||
// schedule
|
// schedule
|
||||||
lua_pushcfunction(lstate, &nlua_schedule);
|
lua_pushcfunction(lstate, &nlua_schedule);
|
||||||
lua_setfield(lstate, -2, "schedule");
|
lua_setfield(lstate, -2, "schedule");
|
||||||
|
Reference in New Issue
Block a user