aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/buffer.c44
-rw-r--r--src/nvim/api/deprecated.c6
-rw-r--r--src/nvim/api/extmark.c8
-rw-r--r--src/nvim/api/private/helpers.c2
-rw-r--r--src/nvim/api/private/helpers.h6
-rw-r--r--src/nvim/api/tabpage.c1
-rw-r--r--src/nvim/api/ui.c20
-rw-r--r--src/nvim/api/win_config.c8
8 files changed, 49 insertions, 46 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 0c68325f40..9b21608ce9 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -247,7 +247,7 @@ void nvim__buf_redraw_range(Buffer buffer, Integer first, Integer last, Error *e
return;
}
- redraw_buf_range_later(buf, (linenr_T)first+1, (linenr_T)last);
+ redraw_buf_range_later(buf, (linenr_T)first + 1, (linenr_T)last);
}
/// Gets a line-range from the buffer.
@@ -495,7 +495,7 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
(long)extra,
kExtmarkNOOP);
- extmark_splice(curbuf, (int)start-1, 0, (int)(end-start), 0,
+ extmark_splice(curbuf, (int)start - 1, 0, (int)(end - start), 0,
deleted_bytes, (int)new_len, 0, inserted_bytes,
kExtmarkUndo);
@@ -602,15 +602,15 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
int64_t lnum = start_row + i;
const char *bufline = (char *)ml_get_buf(buf, lnum, false);
- old_byte += (bcount_t)(strlen(bufline))+1;
+ old_byte += (bcount_t)(strlen(bufline)) + 1;
}
- old_byte += (bcount_t)end_col+1;
+ old_byte += (bcount_t)end_col + 1;
}
String first_item = replacement.items[0].data.string;
- String last_item = replacement.items[replacement.size-1].data.string;
+ String last_item = replacement.items[replacement.size - 1].data.string;
- size_t firstlen = (size_t)start_col+first_item.size;
+ size_t firstlen = (size_t)start_col + first_item.size;
size_t last_part_len = strlen(str_at_end) - (size_t)end_col;
if (replacement.size == 1) {
firstlen += last_part_len;
@@ -618,32 +618,32 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
char *first = xmallocz(firstlen);
char *last = NULL;
memcpy(first, str_at_start, (size_t)start_col);
- memcpy(first+start_col, first_item.data, first_item.size);
- memchrsub(first+start_col, NUL, NL, first_item.size);
+ memcpy(first + start_col, first_item.data, first_item.size);
+ memchrsub(first + start_col, NUL, NL, first_item.size);
if (replacement.size == 1) {
- memcpy(first+start_col+first_item.size, str_at_end+end_col, last_part_len);
+ memcpy(first + start_col + first_item.size, str_at_end + end_col, last_part_len);
} else {
- last = xmallocz(last_item.size+last_part_len);
+ last = xmallocz(last_item.size + last_part_len);
memcpy(last, last_item.data, last_item.size);
memchrsub(last, NUL, NL, last_item.size);
- memcpy(last+last_item.size, str_at_end+end_col, last_part_len);
+ memcpy(last + last_item.size, str_at_end + end_col, last_part_len);
}
char **lines = xcalloc(new_len, sizeof(char *));
lines[0] = first;
new_byte += (bcount_t)(first_item.size);
- for (size_t i = 1; i < new_len-1; i++) {
+ for (size_t i = 1; i < new_len - 1; i++) {
const String l = replacement.items[i].data.string;
// Fill lines[i] with l's contents. Convert NULs to newlines as required by
// NL-used-for-NUL.
lines[i] = xmemdupz(l.data, l.size);
memchrsub(lines[i], NUL, NL, l.size);
- new_byte += (bcount_t)(l.size)+1;
+ new_byte += (bcount_t)(l.size) + 1;
}
if (replacement.size > 1) {
- lines[replacement.size-1] = last;
- new_byte += (bcount_t)(last_item.size)+1;
+ lines[replacement.size - 1] = last;
+ new_byte += (bcount_t)(last_item.size) + 1;
}
try_start();
@@ -663,7 +663,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
}
ptrdiff_t extra = 0; // lines added to text, can be negative
- size_t old_len = (size_t)(end_row-start_row+1);
+ size_t old_len = (size_t)(end_row - start_row + 1);
// If the size of the range is reducing (ie, new_len < old_len) we
// need to delete some old_len. We do this at the start, by
@@ -731,9 +731,9 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
colnr_T col_extent = (colnr_T)(end_col
- ((end_row == start_row) ? start_col : 0));
- extmark_splice(buf, (int)start_row-1, (colnr_T)start_col,
- (int)(end_row-start_row), col_extent, old_byte,
- (int)new_len-1, (colnr_T)last_item.size, new_byte,
+ extmark_splice(buf, (int)start_row - 1, (colnr_T)start_col,
+ (int)(end_row - start_row), col_extent, old_byte,
+ (int)new_len - 1, (colnr_T)last_item.size, new_byte,
kExtmarkUndo);
@@ -829,7 +829,7 @@ ArrayOf(String) nvim_buf_get_text(uint64_t channel_id, Buffer buffer,
rv.size = (size_t)(end_row - start_row) + 1;
rv.items = xcalloc(rv.size, sizeof(Object));
- rv.items[0] = STRING_OBJ(buf_get_text(buf, start_row, start_col, MAXCOL-1, replace_nl, err));
+ rv.items[0] = STRING_OBJ(buf_get_text(buf, start_row, start_col, MAXCOL - 1, replace_nl, err));
if (ERROR_SET(err)) {
goto end;
}
@@ -842,7 +842,7 @@ ArrayOf(String) nvim_buf_get_text(uint64_t channel_id, Buffer buffer,
}
}
- rv.items[rv.size-1] = STRING_OBJ(buf_get_text(buf, end_row, 0, end_col, replace_nl, err));
+ rv.items[rv.size - 1] = STRING_OBJ(buf_get_text(buf, end_row, 0, end_col, replace_nl, err));
if (ERROR_SET(err)) {
goto end;
}
@@ -889,7 +889,7 @@ Integer nvim_buf_get_offset(Buffer buffer, Integer index, Error *err)
return 0;
}
- return ml_find_line_or_offset(buf, (int)index+1, NULL, true);
+ return ml_find_line_or_offset(buf, (int)index + 1, NULL, true);
}
/// Gets a buffer-scoped (b:) variable.
diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c
index 6a41df0aa9..f968593e47 100644
--- a/src/nvim/api/deprecated.c
+++ b/src/nvim/api/deprecated.c
@@ -192,7 +192,7 @@ String buffer_get_line(Buffer buffer, Integer index, Error *err)
String rv = { .size = 0 };
index = convert_index(index);
- Array slice = nvim_buf_get_lines(0, buffer, index, index+1, true, err);
+ Array slice = nvim_buf_get_lines(0, buffer, index, index + 1, true, err);
if (!ERROR_SET(err) && slice.size) {
rv = slice.items[0].data.string;
@@ -221,7 +221,7 @@ void buffer_set_line(Buffer buffer, Integer index, String line, Error *err)
Object l = STRING_OBJ(line);
Array array = { .items = &l, .size = 1 };
index = convert_index(index);
- nvim_buf_set_lines(0, buffer, index, index+1, true, array, err);
+ nvim_buf_set_lines(0, buffer, index, index + 1, true, array, err);
}
/// Deletes a buffer line
@@ -239,7 +239,7 @@ void buffer_del_line(Buffer buffer, Integer index, Error *err)
{
Array array = ARRAY_DICT_INIT;
index = convert_index(index);
- nvim_buf_set_lines(0, buffer, index, index+1, true, array, err);
+ nvim_buf_set_lines(0, buffer, index, index + 1, true, array, err);
}
/// Retrieves a line range from the buffer
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index 8dca37a321..e408d88854 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -546,6 +546,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
goto error;
}
+ // uncrustify:off
+
struct {
const char *name;
Object *opt;
@@ -559,6 +561,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
{ NULL, NULL, NULL },
};
+ // uncrustify:on
+
for (int j = 0; hls[j].name && hls[j].dest; j++) {
if (HAS_KEY(*hls[j].opt)) {
*hls[j].dest = object_to_hl_id(*hls[j].opt, hls[j].name, err);
@@ -716,7 +720,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
line = buf->b_ml.ml_line_count;
}
} else if (line < buf->b_ml.ml_line_count) {
- len = ephemeral ? MAXCOL : STRLEN(ml_get_buf(buf, (linenr_T)line+1, false));
+ len = ephemeral ? MAXCOL : STRLEN(ml_get_buf(buf, (linenr_T)line + 1, false));
}
if (col == -1) {
@@ -923,7 +927,7 @@ void nvim_buf_clear_namespace(Buffer buffer, Integer ns_id, Integer line_start,
}
extmark_clear(buf, (ns_id < 0 ? 0 : (uint32_t)ns_id),
(int)line_start, 0,
- (int)line_end-1, MAXCOL);
+ (int)line_end - 1, MAXCOL);
}
/// Set or change decoration provider for a namespace
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 8383f29400..1c43564dca 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -1245,7 +1245,7 @@ VirtText parse_virt_text(Array chunks, Error *err, int *width)
if (ERROR_SET(err)) {
goto free_exit;
}
- if (j < arr.size-1) {
+ if (j < arr.size - 1) {
kv_push(virt_text, ((VirtTextChunk){ .text = NULL,
.hl_id = hl_id }));
}
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 650349cde7..bbbc3de7d5 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -140,9 +140,9 @@ typedef struct {
// Useful macro for executing some `code` for each item in an array.
#define FOREACH_ITEM(a, __foreach_item, code) \
- for (size_t (__foreach_item ## _index) = 0; (__foreach_item ## _index) < (a).size; \
- (__foreach_item ## _index)++) { \
- Object __foreach_item = (a).items[__foreach_item ## _index]; \
+ for (size_t (__foreach_item##_index) = 0; (__foreach_item##_index) < (a).size; \
+ (__foreach_item##_index)++) { \
+ Object __foreach_item = (a).items[__foreach_item##_index]; \
code; \
}
diff --git a/src/nvim/api/tabpage.c b/src/nvim/api/tabpage.c
index b994d18c43..b81fc3b7d7 100644
--- a/src/nvim/api/tabpage.c
+++ b/src/nvim/api/tabpage.c
@@ -150,4 +150,3 @@ Boolean nvim_tabpage_is_valid(Tabpage tabpage)
api_clear_error(&stub);
return ret;
}
-
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index 383c9c16ab..997f0c218a 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -475,9 +475,9 @@ static void remote_ui_grid_scroll(UI *ui, Integer grid, Integer top, Integer bot
} else {
Array args = ARRAY_DICT_INIT;
ADD(args, INTEGER_OBJ(top));
- ADD(args, INTEGER_OBJ(bot-1));
+ ADD(args, INTEGER_OBJ(bot - 1));
ADD(args, INTEGER_OBJ(left));
- ADD(args, INTEGER_OBJ(right-1));
+ ADD(args, INTEGER_OBJ(right - 1));
push_call(ui, "set_scroll_region", args);
args = (Array)ARRAY_DICT_INIT;
@@ -488,9 +488,9 @@ static void remote_ui_grid_scroll(UI *ui, Integer grid, Integer top, Integer bot
// so reset it.
args = (Array)ARRAY_DICT_INIT;
ADD(args, INTEGER_OBJ(0));
- ADD(args, INTEGER_OBJ(ui->height-1));
+ ADD(args, INTEGER_OBJ(ui->height - 1));
ADD(args, INTEGER_OBJ(0));
- ADD(args, INTEGER_OBJ(ui->width-1));
+ ADD(args, INTEGER_OBJ(ui->width - 1));
push_call(ui, "set_scroll_region", args);
}
}
@@ -615,12 +615,12 @@ static void remote_ui_raw_line(UI *ui, Integer grid, Integer row, Integer startc
ADD(args, INTEGER_OBJ(startcol));
Array cells = ARRAY_DICT_INIT;
int repeat = 0;
- size_t ncells = (size_t)(endcol-startcol);
+ size_t ncells = (size_t)(endcol - startcol);
int last_hl = -1;
for (size_t i = 0; i < ncells; i++) {
repeat++;
- if (i == ncells-1 || attrs[i] != attrs[i+1]
- || STRCMP(chunk[i], chunk[i+1])) {
+ if (i == ncells - 1 || attrs[i] != attrs[i + 1]
+ || STRCMP(chunk[i], chunk[i + 1])) {
Array cell = ARRAY_DICT_INIT;
ADD(cell, STRING_OBJ(cstr_to_string((const char *)chunk[i])));
if (attrs[i] != last_hl || repeat > 1) {
@@ -638,15 +638,15 @@ static void remote_ui_raw_line(UI *ui, Integer grid, Integer row, Integer startc
Array cell = ARRAY_DICT_INIT;
ADD(cell, STRING_OBJ(cstr_to_string(" ")));
ADD(cell, INTEGER_OBJ(clearattr));
- ADD(cell, INTEGER_OBJ(clearcol-endcol));
+ ADD(cell, INTEGER_OBJ(clearcol - endcol));
ADD(cells, ARRAY_OBJ(cell));
}
ADD(args, ARRAY_OBJ(cells));
push_call(ui, "grid_line", args);
} else {
- for (int i = 0; i < endcol-startcol; i++) {
- remote_ui_cursor_goto(ui, row, startcol+i);
+ for (int i = 0; i < endcol - startcol; i++) {
+ remote_ui_cursor_goto(ui, row, startcol + i);
remote_ui_highlight_set(ui, attrs[i]);
remote_ui_put(ui, (const char *)chunk[i]);
if (utf_ambiguous_width(utf_ptr2char(chunk[i]))) {
diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c
index 5e37596884..e7704f72d7 100644
--- a/src/nvim/api/win_config.c
+++ b/src/nvim/api/win_config.c
@@ -354,7 +354,7 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err)
if (style.type == kObjectTypeArray) {
Array arr = style.data.array;
size_t size = arr.size;
- if (!size || size > 8 || (size & (size-1))) {
+ if (!size || size > 8 || (size & (size - 1))) {
api_set_error(err, kErrorTypeValidation,
"invalid number of border chars");
return;
@@ -392,7 +392,7 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err)
"border chars must be one cell");
return;
}
- size_t len = MIN(string.size, sizeof(*chars)-1);
+ size_t len = MIN(string.size, sizeof(*chars) - 1);
if (len) {
memcpy(chars[i], string.data, len);
}
@@ -400,8 +400,8 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err)
hl_ids[i] = hl_id;
}
while (size < 8) {
- memcpy(chars+size, chars, sizeof(*chars) * size);
- memcpy(hl_ids+size, hl_ids, sizeof(*hl_ids) * size);
+ memcpy(chars + size, chars, sizeof(*chars) * size);
+ memcpy(hl_ids + size, hl_ids, sizeof(*hl_ids) * size);
size <<= 1;
}
if ((chars[7][0] && chars[1][0] && !chars[0][0])