aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/autocmd.c4
-rw-r--r--src/nvim/api/buffer.c8
-rw-r--r--src/nvim/api/extmark.c4
-rw-r--r--src/nvim/api/private/converter.c5
-rw-r--r--src/nvim/api/private/helpers.c28
-rw-r--r--src/nvim/api/vim.c2
6 files changed, 27 insertions, 24 deletions
diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c
index 010c03e505..76e531e7aa 100644
--- a/src/nvim/api/autocmd.c
+++ b/src/nvim/api/autocmd.c
@@ -64,6 +64,7 @@ static int64_t next_autocmd_id = 1;
/// containing the following fields:
/// - id (number): the autocommand id (only when defined with the API).
/// - group (integer): the autocommand group id.
+/// - group_name (string): the autocommand group name.
/// - desc (string): the autocommand description.
/// - event (string): the autocommand event.
/// - command (string): the autocommand command.
@@ -269,6 +270,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
if (ap->group != AUGROUP_DEFAULT) {
PUT(autocmd_info, "group", INTEGER_OBJ(ap->group));
+ PUT(autocmd_info, "group_name", CSTR_TO_OBJ(augroup_name(ap->group)));
}
if (ac->id > 0) {
@@ -460,7 +462,7 @@ Integer nvim_create_autocmd(uint64_t channel_id, Object event, Dict(create_autoc
cb.data.luaref = api_new_luaref(callback->data.luaref);
} else if (callback->type == kObjectTypeString) {
cb.type = kCallbackFuncref;
- cb.data.funcref = (char_u *)string_to_cstr(callback->data.string);
+ cb.data.funcref = string_to_cstr(callback->data.string);
} else {
api_set_error(err,
kErrorTypeException,
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index b4d4265a37..45dadae1dd 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -452,7 +452,7 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
goto end;
}
- if (ml_replace((linenr_T)lnum, (char_u *)lines[i], false) == FAIL) {
+ if (ml_replace((linenr_T)lnum, lines[i], false) == FAIL) {
api_set_error(err, kErrorTypeException, "Failed to replace line");
goto end;
}
@@ -472,7 +472,7 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
goto end;
}
- if (ml_append((linenr_T)lnum, (char_u *)lines[i], 0, false) == FAIL) {
+ if (ml_append((linenr_T)lnum, lines[i], 0, false) == FAIL) {
api_set_error(err, kErrorTypeException, "Failed to insert line");
goto end;
}
@@ -692,7 +692,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
goto end;
}
- if (ml_replace((linenr_T)lnum, (char_u *)lines[i], false) == FAIL) {
+ if (ml_replace((linenr_T)lnum, lines[i], false) == FAIL) {
api_set_error(err, kErrorTypeException, "Failed to replace line");
goto end;
}
@@ -710,7 +710,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
goto end;
}
- if (ml_append((linenr_T)lnum, (char_u *)lines[i], 0, false) == FAIL) {
+ if (ml_append((linenr_T)lnum, lines[i], 0, false) == FAIL) {
api_set_error(err, kErrorTypeException, "Failed to insert line");
goto end;
}
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index fa6923e6d5..bbc1ee9d71 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -688,8 +688,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
}
if (opts->sign_text.type == kObjectTypeString) {
- if (!init_sign_text(&decor.sign_text,
- (char_u *)opts->sign_text.data.string.data)) {
+ if (!init_sign_text((char **)&decor.sign_text,
+ opts->sign_text.data.string.data)) {
api_set_error(err, kErrorTypeValidation, "sign_text is not a valid value");
goto error;
}
diff --git a/src/nvim/api/private/converter.c b/src/nvim/api/private/converter.c
index a26383ec7d..8724ef4432 100644
--- a/src/nvim/api/private/converter.c
+++ b/src/nvim/api/private/converter.c
@@ -353,9 +353,10 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err)
case kObjectTypeLuaRef: {
LuaCFunctionState *state = xmalloc(sizeof(LuaCFunctionState));
state->lua_callable.func_ref = api_new_luaref(obj.data.luaref);
- char_u *name = register_cfunc(&nlua_CFunction_func_call, &nlua_CFunction_func_free, state);
+ char *name =
+ (char *)register_cfunc(&nlua_CFunction_func_call, &nlua_CFunction_func_free, state);
tv->v_type = VAR_FUNC;
- tv->vval.v_string = vim_strsave(name);
+ tv->vval.v_string = xstrdup(name);
break;
}
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index a89a254f20..9f894d5533 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -634,8 +634,8 @@ void modify_keymap(uint64_t channel_id, Buffer buffer, bool is_unmap, String mod
}
parsed_args.buffer = !global;
- set_maparg_lhs_rhs((char_u *)lhs.data, lhs.size,
- (char_u *)rhs.data, rhs.size, lua_funcref,
+ set_maparg_lhs_rhs(lhs.data, lhs.size,
+ rhs.data, rhs.size, lua_funcref,
CPO_TO_CPO_FLAGS, &parsed_args);
if (opts != NULL && opts->desc.type == kObjectTypeString) {
parsed_args.desc = string_to_cstr(opts->desc.data.string);
@@ -652,16 +652,16 @@ void modify_keymap(uint64_t channel_id, Buffer buffer, bool is_unmap, String mod
goto fail_and_free;
}
int mode_val; // integer value of the mapping mode, to be passed to do_map()
- char_u *p = (char_u *)((mode.size) ? mode.data : "m");
+ char *p = (mode.size) ? mode.data : "m";
if (STRNCMP(p, "!", 2) == 0) {
- mode_val = get_map_mode(&p, true); // mapmode-ic
+ mode_val = get_map_mode((char_u **)&p, true); // mapmode-ic
} else {
- mode_val = get_map_mode(&p, false);
+ mode_val = get_map_mode((char_u **)&p, false);
if ((mode_val == VISUAL + SELECTMODE + NORMAL + OP_PENDING)
&& mode.size > 0) {
// get_map_mode() treats unrecognized mode shortnames as ":map".
// This is an error unless the given shortname was empty string "".
- api_set_error(err, kErrorTypeValidation, "Invalid mode shortname: \"%s\"", (char *)p);
+ api_set_error(err, kErrorTypeValidation, "Invalid mode shortname: \"%s\"", p);
goto fail_and_free;
}
}
@@ -1269,7 +1269,7 @@ VirtText parse_virt_text(Array chunks, Error *err, int *width)
}
char *text = transstr(str.size > 0 ? str.data : "", false); // allocates
- w += (int)mb_string2cells((char_u *)text);
+ w += (int)mb_string2cells(text);
kv_push(virt_text, ((VirtTextChunk){ .text = text, .hl_id = hl_id }));
}
@@ -1658,19 +1658,19 @@ sctx_T api_set_sctx(uint64_t channel_id)
// adapted from sign.c:sign_define_init_text.
// TODO(lewis6991): Consider merging
-int init_sign_text(char_u **sign_text, char_u *text)
+int init_sign_text(char **sign_text, char *text)
{
- char_u *s;
+ char *s;
- char_u *endp = text + (int)STRLEN(text);
+ char *endp = text + (int)STRLEN(text);
// Count cells and check for non-printable chars
int cells = 0;
- for (s = text; s < endp; s += utfc_ptr2len(s)) {
- if (!vim_isprintc(utf_ptr2char(s))) {
+ for (s = text; s < endp; s += utfc_ptr2len((char_u *)s)) {
+ if (!vim_isprintc(utf_ptr2char((char_u *)s))) {
break;
}
- cells += utf_ptr2cells(s);
+ cells += utf_ptr2cells((char_u *)s);
}
// Currently must be empty, one or two display cells
if (s != endp || cells > 2) {
@@ -1683,7 +1683,7 @@ int init_sign_text(char_u **sign_text, char_u *text)
// Allocate one byte more if we need to pad up
// with a space.
size_t len = (size_t)(endp - text + ((cells == 1) ? 1 : 0));
- *sign_text = vim_strnsave(text, len);
+ *sign_text = xstrnsave(text, len);
if (cells == 1) {
STRCPY(*sign_text + len - 1, " ");
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 2323b8db47..7f4fafa71b 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -474,7 +474,7 @@ Integer nvim_strwidth(String text, Error *err)
return 0;
}
- return (Integer)mb_string2cells((char_u *)text.data);
+ return (Integer)mb_string2cells(text.data);
}
/// Gets the paths contained in 'runtimepath'.