mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
feat(ts): expose minimum language version to lua (#17186)
This commit is contained in:
parent
f9080b24c4
commit
8c140be31f
@ -11,6 +11,7 @@ local parsers = {}
|
|||||||
local M = vim.tbl_extend("error", query, language)
|
local M = vim.tbl_extend("error", query, language)
|
||||||
|
|
||||||
M.language_version = vim._ts_get_language_version()
|
M.language_version = vim._ts_get_language_version()
|
||||||
|
M.minimum_language_version = vim._ts_get_minimum_language_version()
|
||||||
|
|
||||||
setmetatable(M, {
|
setmetatable(M, {
|
||||||
__index = function (t, k)
|
__index = function (t, k)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
|
#include <tree_sitter/api.h>
|
||||||
|
|
||||||
#include "luv/luv.h"
|
#include "luv/luv.h"
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
@ -1267,6 +1268,12 @@ int tslua_get_language_version(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tslua_get_minimum_language_version(lua_State *L)
|
||||||
|
{
|
||||||
|
lua_pushnumber(L, TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static void nlua_add_treesitter(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
static void nlua_add_treesitter(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
tslua_init(lstate);
|
tslua_init(lstate);
|
||||||
@ -1288,6 +1295,9 @@ static void nlua_add_treesitter(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
|||||||
|
|
||||||
lua_pushcfunction(lstate, tslua_get_language_version);
|
lua_pushcfunction(lstate, tslua_get_language_version);
|
||||||
lua_setfield(lstate, -2, "_ts_get_language_version");
|
lua_setfield(lstate, -2, "_ts_get_language_version");
|
||||||
|
|
||||||
|
lua_pushcfunction(lstate, tslua_get_minimum_language_version);
|
||||||
|
lua_setfield(lstate, -2, "_ts_get_minimum_language_version");
|
||||||
}
|
}
|
||||||
|
|
||||||
int nlua_expand_pat(expand_T *xp, char_u *pat, int *num_results, char_u ***results)
|
int nlua_expand_pat(expand_T *xp, char_u *pat, int *num_results, char_u ***results)
|
||||||
|
Loading…
Reference in New Issue
Block a user