aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/lua')
-rw-r--r--src/nvim/lua/executor.c9
-rw-r--r--src/nvim/lua/spell.c3
-rw-r--r--src/nvim/lua/stdlib.c16
-rw-r--r--src/nvim/lua/treesitter.c16
-rw-r--r--src/nvim/lua/xdiff.c4
5 files changed, 22 insertions, 26 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 1415ceeaed..c8fc76e20d 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -211,9 +211,7 @@ static int nlua_luv_cfpcall(lua_State *lstate, int nargs, int nresult, int flags
if (status) {
if (status == LUA_ERRMEM && !(flags & LUVF_CALLBACK_NOEXIT)) {
// consider out of memory errors unrecoverable, just like xmalloc()
- os_errmsg(e_outofmem);
- os_errmsg("\n");
- preserve_exit();
+ preserve_exit(e_outofmem);
}
const char *error = lua_tostring(lstate, -1);
@@ -1768,13 +1766,12 @@ bool nlua_exec_file(const char *path)
StringBuilder sb = KV_INITIAL_VALUE;
kv_resize(sb, 64);
- ptrdiff_t read_size = -1;
// Read all input from stdin, unless interrupted (ctrl-c).
while (true) {
if (got_int) { // User canceled.
return false;
}
- read_size = file_read(stdin_dup, IObuff, 64);
+ ptrdiff_t read_size = file_read(stdin_dup, IObuff, 64);
if (read_size < 0) { // Error.
return false;
}
@@ -1995,7 +1992,7 @@ char *nlua_register_table_as_callable(const typval_T *const arg)
void nlua_execute_on_key(int c)
{
char buf[NUMBUFLEN];
- size_t buf_len = special_to_buf(c, mod_mask, false, (char_u *)buf);
+ size_t buf_len = special_to_buf(c, mod_mask, false, buf);
lua_State *const lstate = global_lstate;
diff --git a/src/nvim/lua/spell.c b/src/nvim/lua/spell.c
index d510d25e90..78e023c26d 100644
--- a/src/nvim/lua/spell.c
+++ b/src/nvim/lua/spell.c
@@ -51,7 +51,6 @@ int nlua_spell_check(lua_State *lstate)
}
hlf_T attr = HLF_COUNT;
- size_t len = 0;
size_t pos = 0;
int capcol = -1;
int no_res = 0;
@@ -61,7 +60,7 @@ int nlua_spell_check(lua_State *lstate)
while (*str != NUL) {
attr = HLF_COUNT;
- len = spell_check(curwin, (char *)str, &attr, &capcol, false);
+ size_t len = spell_check(curwin, (char *)str, &attr, &capcol, false);
assert(len <= INT_MAX);
if (attr != HLF_COUNT) {
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c
index 6ebca6d97e..5aeff4de98 100644
--- a/src/nvim/lua/stdlib.c
+++ b/src/nvim/lua/stdlib.c
@@ -78,20 +78,20 @@ static int regex_match_line(lua_State *lstate)
return luaL_error(lstate, "not enough args");
}
- long bufnr = luaL_checkinteger(lstate, 2);
+ handle_T bufnr = (handle_T)luaL_checkinteger(lstate, 2);
linenr_T rownr = (linenr_T)luaL_checkinteger(lstate, 3);
- long start = 0, end = -1;
+ int start = 0, end = -1;
if (narg >= 4) {
- start = luaL_checkinteger(lstate, 4);
+ start = (int)luaL_checkinteger(lstate, 4);
}
if (narg >= 5) {
- end = luaL_checkinteger(lstate, 5);
+ end = (int)luaL_checkinteger(lstate, 5);
if (end < 0) {
return luaL_error(lstate, "invalid end");
}
}
- buf_T *buf = bufnr ? handle_get_buffer((int)bufnr) : curbuf;
+ buf_T *buf = bufnr ? handle_get_buffer(bufnr) : curbuf;
if (!buf || buf->b_ml.ml_mfp == NULL) {
return luaL_error(lstate, "invalid buffer");
}
@@ -218,11 +218,11 @@ static int nlua_str_utf_start(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
{
size_t s1_len;
const char *s1 = luaL_checklstring(lstate, 1, &s1_len);
- long offset = luaL_checkinteger(lstate, 2);
+ ptrdiff_t offset = luaL_checkinteger(lstate, 2);
if (offset < 0 || offset > (intptr_t)s1_len) {
return luaL_error(lstate, "index out of range");
}
- int head_offset = utf_cp_head_off((char_u *)s1, (char_u *)s1 + offset - 1);
+ int head_offset = utf_cp_head_off(s1, s1 + offset - 1);
lua_pushinteger(lstate, head_offset);
return 1;
}
@@ -238,7 +238,7 @@ static int nlua_str_utf_end(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
{
size_t s1_len;
const char *s1 = luaL_checklstring(lstate, 1, &s1_len);
- long offset = luaL_checkinteger(lstate, 2);
+ ptrdiff_t offset = luaL_checkinteger(lstate, 2);
if (offset < 0 || offset > (intptr_t)s1_len) {
return luaL_error(lstate, "index out of range");
}
diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c
index 56f4daed1a..5248ebed14 100644
--- a/src/nvim/lua/treesitter.c
+++ b/src/nvim/lua/treesitter.c
@@ -393,7 +393,7 @@ static int parser_parse(lua_State *L)
TSTree *new_tree = NULL;
size_t len;
const char *str;
- long bufnr;
+ handle_T bufnr;
buf_T *buf;
TSInput input;
@@ -406,13 +406,13 @@ static int parser_parse(lua_State *L)
break;
case LUA_TNUMBER:
- bufnr = lua_tointeger(L, 3);
- buf = handle_get_buffer((handle_T)bufnr);
+ bufnr = (handle_T)lua_tointeger(L, 3);
+ buf = handle_get_buffer(bufnr);
if (!buf) {
#define BUFSIZE 256
char ebuf[BUFSIZE] = { 0 };
- vim_snprintf(ebuf, BUFSIZE, "invalid buffer handle: %ld", bufnr);
+ vim_snprintf(ebuf, BUFSIZE, "invalid buffer handle: %d", bufnr);
return luaL_argerror(L, 3, ebuf);
#undef BUFSIZE
}
@@ -898,8 +898,8 @@ static int node_child(lua_State *L)
if (!node_check(L, 1, &node)) {
return 0;
}
- long num = lua_tointeger(L, 2);
- TSNode child = ts_node_child(node, (uint32_t)num);
+ uint32_t num = (uint32_t)lua_tointeger(L, 2);
+ TSNode child = ts_node_child(node, num);
push_node(L, child, 1);
return 1;
@@ -911,8 +911,8 @@ static int node_named_child(lua_State *L)
if (!node_check(L, 1, &node)) {
return 0;
}
- long num = lua_tointeger(L, 2);
- TSNode child = ts_node_named_child(node, (uint32_t)num);
+ uint32_t num = (uint32_t)lua_tointeger(L, 2);
+ TSNode child = ts_node_named_child(node, num);
push_node(L, child, 1);
return 1;
diff --git a/src/nvim/lua/xdiff.c b/src/nvim/lua/xdiff.c
index 857b159af5..9a7ae5c146 100644
--- a/src/nvim/lua/xdiff.c
+++ b/src/nvim/lua/xdiff.c
@@ -257,13 +257,13 @@ static NluaXdiffMode process_xdl_diff_opts(lua_State *lstate, xdemitconf_t *cfg,
if (check_xdiff_opt(v->type, kObjectTypeInteger, "ctxlen", err)) {
goto exit_1;
}
- cfg->ctxlen = v->data.integer;
+ cfg->ctxlen = (long)v->data.integer;
} else if (strequal("interhunkctxlen", k.data)) {
if (check_xdiff_opt(v->type, kObjectTypeInteger, "interhunkctxlen",
err)) {
goto exit_1;
}
- cfg->interhunkctxlen = v->data.integer;
+ cfg->interhunkctxlen = (long)v->data.integer;
} else if (strequal("linematch", k.data)) {
*linematch = api_object_to_bool(*v, "linematch", false, err);
if (ERROR_SET(err)) {