mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 23:08:16 +00:00
tree-sitter: style
This commit is contained in:
@@ -829,7 +829,6 @@ static int create_tslua_parser(lua_State *L)
|
||||
}
|
||||
|
||||
const char *lang_name = lua_tostring(L, 1);
|
||||
|
||||
return tslua_push_parser(L, lang_name);
|
||||
}
|
||||
|
||||
|
@@ -86,7 +86,6 @@ void build_meta(lua_State *L, const char* tname, const luaL_Reg *meta)
|
||||
/// all global state is stored in the regirstry of the lua_State
|
||||
void tslua_init(lua_State *L)
|
||||
{
|
||||
|
||||
langs = pmap_new(cstr_t)();
|
||||
|
||||
// type metatables
|
||||
@@ -129,12 +128,14 @@ int ts_lua_register_lang(lua_State *L)
|
||||
// at exit, to keep LeakSanitizer happy.
|
||||
uv_lib_t lib;
|
||||
if (uv_dlopen(path, &lib)) {
|
||||
return luaL_error(L, "Failed to load parser: uv_dlopen: %s", uv_dlerror(&lib));
|
||||
return luaL_error(L, "Failed to load parser: uv_dlopen: %s",
|
||||
uv_dlerror(&lib));
|
||||
}
|
||||
|
||||
TSLanguage *(*lang_parser)(void);
|
||||
if (uv_dlsym(&lib, symbol_buf, (void **)&lang_parser)) {
|
||||
return luaL_error(L, "Failed to load parser: uv_dlsym: %s", uv_dlerror(&lib));
|
||||
return luaL_error(L, "Failed to load parser: uv_dlsym: %s",
|
||||
uv_dlerror(&lib));
|
||||
}
|
||||
|
||||
TSLanguage *lang = lang_parser();
|
||||
@@ -192,17 +193,19 @@ static int parser_tostring(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const char *input_cb(void *payload, uint32_t byte_index, TSPoint position, uint32_t *bytes_read)
|
||||
static const char *input_cb(void *payload, uint32_t byte_index,
|
||||
TSPoint position, uint32_t *bytes_read)
|
||||
{
|
||||
buf_T *bp = payload;
|
||||
static char buf[200];
|
||||
#define BUFSIZE 256
|
||||
static char buf[BUFSIZE];
|
||||
if ((linenr_T)position.row >= bp->b_ml.ml_line_count) {
|
||||
*bytes_read = 0;
|
||||
return "";
|
||||
}
|
||||
char_u *line = ml_get_buf(bp, position.row+1, false);
|
||||
size_t len = STRLEN(line);
|
||||
size_t tocopy = MIN(len-position.column,200);
|
||||
size_t tocopy = MIN(len-position.column, BUFSIZE);
|
||||
|
||||
// TODO: translate embedded \n to \000
|
||||
memcpy(buf, line+position.column, tocopy);
|
||||
@@ -212,6 +215,7 @@ static const char *input_cb(void *payload, uint32_t byte_index, TSPoint position
|
||||
(*bytes_read)++;
|
||||
}
|
||||
return buf;
|
||||
#undef BUFSIZE
|
||||
}
|
||||
|
||||
static int parser_parse_buf(lua_State *L)
|
||||
@@ -253,8 +257,7 @@ static int parser_edit(lua_State *L)
|
||||
{
|
||||
if (lua_gettop(L) < 10) {
|
||||
lua_pushstring(L, "not enough args to parser:edit()");
|
||||
lua_error(L);
|
||||
return 0; // unreachable
|
||||
return lua_error(L);
|
||||
}
|
||||
|
||||
Tslua_parser *p = parser_check(L);
|
||||
|
Reference in New Issue
Block a user