mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test(treesitter): make internal lang test pending when necessary
This commit is contained in:
parent
b1eaa2b9a3
commit
26ebf67c39
@ -1662,6 +1662,9 @@ static void nlua_add_treesitter(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
|||||||
lua_pushcfunction(lstate, tslua_has_language);
|
lua_pushcfunction(lstate, tslua_has_language);
|
||||||
lua_setfield(lstate, -2, "_ts_has_language");
|
lua_setfield(lstate, -2, "_ts_has_language");
|
||||||
|
|
||||||
|
lua_pushcfunction(lstate, tslua_remove_lang);
|
||||||
|
lua_setfield(lstate, -2, "_ts_remove_language");
|
||||||
|
|
||||||
lua_pushcfunction(lstate, tslua_inspect_lang);
|
lua_pushcfunction(lstate, tslua_inspect_lang);
|
||||||
lua_setfield(lstate, -2, "_ts_inspect_language");
|
lua_setfield(lstate, -2, "_ts_inspect_language");
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "nvim/lib/kvec.h"
|
#include "nvim/lib/kvec.h"
|
||||||
#include "nvim/log.h"
|
#include "nvim/log.h"
|
||||||
#include "nvim/lua/treesitter.h"
|
#include "nvim/lua/treesitter.h"
|
||||||
|
#include "nvim/map.h"
|
||||||
#include "nvim/memline.h"
|
#include "nvim/memline.h"
|
||||||
#include "tree_sitter/api.h"
|
#include "tree_sitter/api.h"
|
||||||
|
|
||||||
@ -210,6 +211,17 @@ int tslua_add_language(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tslua_remove_lang(lua_State *L)
|
||||||
|
{
|
||||||
|
const char *lang_name = luaL_checkstring(L, 1);
|
||||||
|
bool present = pmap_has(cstr_t)(&langs, lang_name);
|
||||||
|
if (present) {
|
||||||
|
pmap_del(cstr_t)(&langs, lang_name);
|
||||||
|
}
|
||||||
|
lua_pushboolean(L, present);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int tslua_inspect_lang(lua_State *L)
|
int tslua_inspect_lang(lua_State *L)
|
||||||
{
|
{
|
||||||
const char *lang_name = luaL_checkstring(L, 1);
|
const char *lang_name = luaL_checkstring(L, 1);
|
||||||
|
@ -761,6 +761,7 @@ function module.pending_c_parser(pending_fn)
|
|||||||
pending_fn 'no C parser, skipping'
|
pending_fn 'no C parser, skipping'
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
module.exec_lua [[vim._ts_remove_language 'c']]
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,8 +27,10 @@ describe('treesitter language API', function()
|
|||||||
eq("Error executing lua: .../language.lua:0: no parser for 'borklang' language, see :help treesitter-parsers",
|
eq("Error executing lua: .../language.lua:0: no parser for 'borklang' language, see :help treesitter-parsers",
|
||||||
pcall_err(exec_lua, "parser = vim.treesitter.inspect_language('borklang')"))
|
pcall_err(exec_lua, "parser = vim.treesitter.inspect_language('borklang')"))
|
||||||
|
|
||||||
matches("Error executing lua: Failed to load parser: uv_dlsym: .+",
|
if not pending_c_parser(pending) then
|
||||||
pcall_err(exec_lua, "parser = vim.treesitter.require_language('c', nil, false, 'borklang')"))
|
matches("Error executing lua: Failed to load parser: uv_dlsym: .+",
|
||||||
|
pcall_err(exec_lua, 'vim.treesitter.require_language("c", nil, false, "borklang")'))
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('inspects language', function()
|
it('inspects language', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user