diff options
Diffstat (limited to 'src/nvim/lua')
-rw-r--r-- | src/nvim/lua/converter.c | 2 | ||||
-rw-r--r-- | src/nvim/lua/executor.c | 26 | ||||
-rw-r--r-- | src/nvim/lua/stdlib.c | 10 | ||||
-rw-r--r-- | src/nvim/lua/treesitter.c | 24 | ||||
-rw-r--r-- | src/nvim/lua/xdiff.c | 2 |
5 files changed, 31 insertions, 33 deletions
diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index ef49a03660..daf3a32a98 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -1236,7 +1236,7 @@ LuaRef nlua_pop_LuaRef(lua_State *const lstate, Error *err) type ret; \ if (lua_type(lstate, -1) != LUA_TNUMBER) { \ api_set_error(err, kErrorTypeValidation, "Expected Lua number"); \ - ret = (type)-1; \ + ret = (type) - 1; \ } else { \ ret = (type)lua_tonumber(lstate, -1); \ } \ diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 81396f1715..2c4d527fdf 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -332,8 +332,7 @@ static int nlua_schedule(lua_State *const lstate) // Dummy timer callback. Used by f_wait(). static void dummy_timer_due_cb(TimeWatcher *tw, void *data) -{ -} +{} // Dummy timer close callback. Used by f_wait(). static void dummy_timer_close_cb(TimeWatcher *tw, void *data) @@ -543,9 +542,9 @@ static int nlua_module_preloader(lua_State *lstate) ModuleDef def = builtin_modules[i]; char name[256]; name[0] = '@'; - size_t off = xstrlcpy(name+1, def.name, (sizeof name) - 2); - strchrsub(name+1, '.', '/'); - xstrlcpy(name+1+off, ".lua", (sizeof name)-2-off); + size_t off = xstrlcpy(name + 1, def.name, (sizeof name) - 2); + strchrsub(name + 1, '.', '/'); + xstrlcpy(name + 1 + off, ".lua", (sizeof name) - 2 - off); if (luaL_loadbuffer(lstate, (const char *)def.data, def.size - 1, name)) { return lua_error(lstate); @@ -769,7 +768,7 @@ static void nlua_common_free_all_mem(lua_State *lstate) static void nlua_print_event(void **argv) { char *str = argv[0]; - const size_t len = (size_t)(intptr_t)argv[1]-1; // exclude final NUL + const size_t len = (size_t)(intptr_t)argv[1] - 1; // exclude final NUL for (size_t i = 0; i < len;) { if (got_int) { @@ -926,7 +925,7 @@ int nlua_call(lua_State *lstate) return luaL_error(lstate, e_luv_api_disabled, "vimL function"); } - int nargs = lua_gettop(lstate)-1; + int nargs = lua_gettop(lstate) - 1; if (nargs > MAX_FUNC_ARGS) { return luaL_error(lstate, "Function called with too many arguments"); } @@ -934,10 +933,10 @@ int nlua_call(lua_State *lstate) typval_T vim_args[MAX_FUNC_ARGS + 1]; int i = 0; // also used for freeing the variables for (; i < nargs; i++) { - lua_pushvalue(lstate, i+2); + lua_pushvalue(lstate, i + 2); if (!nlua_pop_typval(lstate, &vim_args[i])) { api_set_error(&err, kErrorTypeException, - "error converting argument %d", i+1); + "error converting argument %d", i + 1); goto free_vim_args; } } @@ -994,12 +993,12 @@ static int nlua_rpc(lua_State *lstate, bool request) size_t name_len; uint64_t chan_id = (uint64_t)luaL_checkinteger(lstate, 1); const char *name = luaL_checklstring(lstate, 2, &name_len); - int nargs = lua_gettop(lstate)-2; + int nargs = lua_gettop(lstate) - 2; Error err = ERROR_INIT; Array args = ARRAY_DICT_INIT; for (int i = 0; i < nargs; i++) { - lua_pushvalue(lstate, i+3); + lua_pushvalue(lstate, i + 3); ADD(args, nlua_pop_Object(lstate, false, &err)); if (ERROR_SET(&err)) { api_free_array(args); @@ -1415,7 +1414,7 @@ void ex_lua(exarg_T *const eap) // lua nlua_typval_exec doesn't expect null terminated string so len // needs to end before null byte. char *code_buf = xmallocz(len); - vim_snprintf(code_buf, len+1, "vim.pretty_print(%s)", code+1); + vim_snprintf(code_buf, len + 1, "vim.pretty_print(%s)", code + 1); xfree(code); code = code_buf; } @@ -1820,7 +1819,7 @@ void nlua_set_sctx(sctx_T *current) is_ignored = true; } else { for (int i = 0; i < ignorelist_size; i++) { - if (strncmp(ignorelist[i], info->source+1, strlen(ignorelist[i])) == 0) { + if (strncmp(ignorelist[i], info->source + 1, strlen(ignorelist[i])) == 0) { is_ignored = true; break; } @@ -1912,4 +1911,3 @@ void nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap) nlua_error(lstate, _("Error executing Lua callback: %.*s")); } } - diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index e94c61b37c..52a9a1a84f 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -59,8 +59,8 @@ static int regex_match(lua_State *lstate, regprog_T **prog, char_u *str) *prog = rm.regprog; if (match) { - lua_pushinteger(lstate, (lua_Integer)(rm.startp[0]-str)); - lua_pushinteger(lstate, (lua_Integer)(rm.endp[0]-str)); + lua_pushinteger(lstate, (lua_Integer)(rm.startp[0] - str)); + lua_pushinteger(lstate, (lua_Integer)(rm.endp[0] - str)); return 2; } return 0; @@ -110,7 +110,7 @@ static int regex_match_line(lua_State *lstate) return luaL_error(lstate, "invalid row"); } - char_u *line = ml_get_buf(buf, rownr+1, false); + char_u *line = ml_get_buf(buf, rownr + 1, false); size_t len = STRLEN(line); if (start < 0 || (size_t)start > len) { @@ -126,7 +126,7 @@ static int regex_match_line(lua_State *lstate) line[end] = NUL; } - int nret = regex_match(lstate, prog, line+start); + int nret = regex_match(lstate, prog, line + start); if (end >= 0) { line[end] = save; @@ -208,7 +208,7 @@ static int nlua_str_utf_pos(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL size_t idx = 1; size_t clen; for (size_t i = 0; i < s1_len && s1[i] != NUL; i += clen) { - clen = (size_t)utf_ptr2len_len((const char_u *)(s1)+i, (int)(s1_len-i)); + clen = (size_t)utf_ptr2len_len((const char_u *)(s1) + i, (int)(s1_len - i)); lua_pushinteger(lstate, (long)i + 1); lua_rawseti(lstate, -2, (int)idx); idx++; diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index f4067ad02f..a871cd29ce 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -208,7 +208,7 @@ int tslua_inspect_lang(lua_State *L) size_t nsymbols = (size_t)ts_language_symbol_count(lang); - lua_createtable(L, nsymbols-1, 1); // [retval, symbols] + lua_createtable(L, nsymbols - 1, 1); // [retval, symbols] for (size_t i = 0; i < nsymbols; i++) { TSSymbolType t = ts_language_symbol_type(lang, i); if (t == TSSymbolTypeAuxiliary) { @@ -298,15 +298,15 @@ static const char *input_cb(void *payload, uint32_t byte_index, TSPoint position *bytes_read = 0; return ""; } - char_u *line = ml_get_buf(bp, position.row+1, false); + char_u *line = ml_get_buf(bp, position.row + 1, false); size_t len = STRLEN(line); if (position.column > len) { *bytes_read = 0; return ""; } - size_t tocopy = MIN(len-position.column, BUFSIZE); + size_t tocopy = MIN(len - position.column, BUFSIZE); - memcpy(buf, line+position.column, tocopy); + memcpy(buf, line + position.column, tocopy); // Translate embedded \n to NUL memchrsub(buf, '\n', '\0', tocopy); *bytes_read = (uint32_t)tocopy; @@ -334,7 +334,7 @@ static void push_ranges(lua_State *L, const TSRange *ranges, const unsigned int lua_pushinteger(L, ranges[i].end_point.column); lua_rawseti(L, -2, 4); - lua_rawseti(L, -2, i+1); + lua_rawseti(L, -2, i + 1); } } @@ -1037,7 +1037,7 @@ static void set_match(lua_State *L, TSQueryMatch *match, int nodeidx) { for (int i = 0; i < match->capture_count; i++) { push_node(L, match->captures[i].node, nodeidx); - lua_rawseti(L, -2, match->captures[i].index+1); + lua_rawseti(L, -2, match->captures[i].index + 1); } } @@ -1049,7 +1049,7 @@ static int query_next_match(lua_State *L) TSQuery *query = query_check(L, lua_upvalueindex(3)); TSQueryMatch match; if (ts_query_cursor_next_match(cursor, &match)) { - lua_pushinteger(L, match.pattern_index+1); // [index] + lua_pushinteger(L, match.pattern_index + 1); // [index] lua_createtable(L, ts_query_capture_count(query), 2); // [index, match] set_match(L, &match, lua_upvalueindex(2)); return 2; @@ -1082,7 +1082,7 @@ static int query_next_capture(lua_State *L) if (ts_query_cursor_next_capture(cursor, &match, &capture_index)) { TSQueryCapture capture = match.captures[capture_index]; - lua_pushinteger(L, capture.index+1); // [index] + lua_pushinteger(L, capture.index + 1); // [index] push_node(L, capture.node, lua_upvalueindex(2)); // [index, node] // Now check if we need to run the predicates @@ -1094,7 +1094,7 @@ static int query_next_capture(lua_State *L) lua_pushvalue(L, lua_upvalueindex(4)); // [index, node, match] set_match(L, &match, lua_upvalueindex(2)); - lua_pushinteger(L, match.pattern_index+1); + lua_pushinteger(L, match.pattern_index + 1); lua_setfield(L, -2, "pattern"); if (match.capture_count > 1) { @@ -1273,7 +1273,7 @@ static int query_inspect(lua_State *L) &strlen); lua_pushlstring(L, str, strlen); // [retval, patterns, pat, pred, item] } else if (step[k].type == TSQueryPredicateStepTypeCapture) { - lua_pushnumber(L, step[k].value_id+1); // [..., pat, pred, item] + lua_pushnumber(L, step[k].value_id + 1); // [..., pat, pred, item] } else { abort(); } @@ -1281,7 +1281,7 @@ static int query_inspect(lua_State *L) } // last predicate should have ended with TypeDone lua_pop(L, 1); // [retval, patters, pat] - lua_rawseti(L, -2, i+1); // [retval, patterns] + lua_rawseti(L, -2, i + 1); // [retval, patterns] } lua_setfield(L, -2, "patterns"); // [retval] @@ -1291,7 +1291,7 @@ static int query_inspect(lua_State *L) uint32_t strlen; const char *str = ts_query_capture_name_for_id(query, i, &strlen); lua_pushlstring(L, str, strlen); // [retval, captures, capture] - lua_rawseti(L, -2, i+1); + lua_rawseti(L, -2, i + 1); } lua_setfield(L, -2, "captures"); // [retval] diff --git a/src/nvim/lua/xdiff.c b/src/nvim/lua/xdiff.c index 37855630d1..71f85385b6 100644 --- a/src/nvim/lua/xdiff.c +++ b/src/nvim/lua/xdiff.c @@ -74,7 +74,7 @@ static int hunk_locations_cb(long start_a, long count_a, long start_b, long coun lua_pushinteger(lstate, count_b); lua_rawseti(lstate, -2, 4); - lua_rawseti(lstate, -2, (signed)lua_objlen(lstate, -2)+1); + lua_rawseti(lstate, -2, (signed)lua_objlen(lstate, -2) + 1); return 0; } |