treesitter: fix some clint errors

Also fixes some mismatches on the name of the function
This commit is contained in:
Thomas Vigouroux
2020-06-14 19:03:36 +02:00
parent ac18403d6e
commit 75a1239eb5

View File

@@ -218,7 +218,6 @@ int tslua_inspect_lang(lua_State *L)
int tslua_push_parser(lua_State *L) int tslua_push_parser(lua_State *L)
{ {
// Gather language // Gather language
if (lua_gettop(L) < 1 || !lua_isstring(L, 1)) { if (lua_gettop(L) < 1 || !lua_isstring(L, 1)) {
return luaL_error(L, "string expected"); return luaL_error(L, "string expected");
@@ -385,7 +384,8 @@ static int parser_edit(lua_State *L)
return 0; return 0;
} }
static int parser_set_ranges(lua_State *L) { static int parser_set_ranges(lua_State *L)
{
if (lua_gettop(L) < 3) { if (lua_gettop(L) < 3) {
lua_pushstring(L, "not enough args to parser:set_ranges()"); lua_pushstring(L, "not enough args to parser:set_ranges()");
return lua_error(L); return lua_error(L);
@@ -398,8 +398,8 @@ static int parser_set_ranges(lua_State *L) {
int bufnr = lua_tointeger(L, 2); int bufnr = lua_tointeger(L, 2);
if (! lua_istable(L, 3)) { if (!lua_istable(L, 3)) {
lua_pushstring(L, "argument for parser:set_ranges() should be a table."); lua_pushstring(L, "argument for parser:set_included_ranges() should be a table.");
return lua_error(L); return lua_error(L);
} }
@@ -413,13 +413,17 @@ static int parser_set_ranges(lua_State *L) {
if (!lua_istable(L, -1)) { if (!lua_istable(L, -1)) {
xfree(ranges); xfree(ranges);
lua_pushstring(L, "argument for parser:set_ranges() should be a table of tables."); lua_pushstring(
L,
"argument for parser:set_included_ranges() should be a table of tables.");
return lua_error(L); return lua_error(L);
} }
if (lua_objlen(L, -1) < 4 ) { if (lua_objlen(L, -1) < 4) {
xfree(ranges); xfree(ranges);
lua_pushstring(L, "argument for parser:set_ranges() should be a table of ranges of 4 elements."); lua_pushstring(
L,
"argument for parser:set_included_ranges() should be a table of ranges of 4 elements.");
return lua_error(L); return lua_error(L);
} }
@@ -446,10 +450,13 @@ static int parser_set_ranges(lua_State *L) {
buf = curbuf; buf = curbuf;
} }
// TODO: For sure that's wrong, try to find a way to get the byte offset directly // TODO(vigoux): For sure that's wrong, try to find a way to get the
// byte offset directly
// Lines are 0 based for consistency // Lines are 0 based for consistency
uint32_t start_byte = ml_find_line_or_offset(buf, start_row + 1, NULL, false) + start_col; uint32_t start_byte =
uint32_t stop_byte = ml_find_line_or_offset(buf, stop_row + 1, NULL, false) + stop_col; ml_find_line_or_offset(buf, start_row + 1, NULL, false) + start_col;
uint32_t stop_byte =
ml_find_line_or_offset(buf, stop_row + 1, NULL, false) + stop_col;
ranges[index] = (TSRange) { ranges[index] = (TSRange) {
.start_point = (TSPoint) { .start_point = (TSPoint) {