diff options
-rw-r--r-- | runtime/doc/change.txt | 17 | ||||
-rw-r--r-- | runtime/doc/index.txt | 2 | ||||
-rw-r--r-- | runtime/doc/visual.txt | 2 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 13 | ||||
-rwxr-xr-x | src/nvim/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/nvim/api/vimscript.c | 13 | ||||
-rw-r--r-- | src/nvim/buffer_updates.c | 2 | ||||
-rw-r--r-- | src/nvim/edit.c | 100 | ||||
-rw-r--r-- | src/nvim/eval.c | 2 | ||||
-rw-r--r-- | src/nvim/eval.h | 2 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 28 | ||||
-rw-r--r-- | src/nvim/extmark.c | 14 | ||||
-rw-r--r-- | src/nvim/extmark.h | 2 | ||||
-rw-r--r-- | src/nvim/globals.h | 2 | ||||
-rw-r--r-- | src/nvim/lib/kbtree.h | 160 | ||||
-rw-r--r-- | src/nvim/marktree.c | 4 | ||||
-rw-r--r-- | src/nvim/normal.c | 12 | ||||
-rw-r--r-- | src/nvim/shada.c | 2 | ||||
-rw-r--r-- | src/nvim/strings.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_visual.vim | 80 | ||||
-rw-r--r-- | src/uncrustify.cfg | 224 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 11 |
22 files changed, 435 insertions, 260 deletions
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 8e666484d7..a868983a61 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1116,14 +1116,15 @@ register. With blockwise selection it also depends on the size of the block and whether the corners are on an existing character. (Implementation detail: it actually works by first putting the register after the selection and then deleting the selection.) -With 'p' the previously selected text is put in the unnamed register. This is -useful if you want to put that text somewhere else. But you cannot repeat the -same change. -With 'P' the unnamed register is not changed, you can repeat the same change. -But the deleted text cannot be used. If you do need it you can use 'p' with -another register. E.g., yank the text to copy, Visually select the text to -replace and use "0p . You can repeat this as many times as you like, and the -unnamed register will be changed each time. +With |p| the previously selected text is put in the unnamed register (and +possibly the selection and/or clipboard). This is useful if you want to put +that text somewhere else. But you cannot repeat the same change. +With |P| the unnamed register is not changed (and neither the selection or +clipboard), you can repeat the same change. But the deleted text cannot be +used. If you do need it you can use |p| with another register. E.g., yank +the text to copy, Visually select the text to replace and use "0p . You can +repeat this as many times as you like, and the unnamed register will be +changed each time. When you use a blockwise Visual mode command and yank only a single line into a register, a paste on a visual selected area will paste that single line on diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 572b4e3f93..5c36eaf8e5 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -927,7 +927,7 @@ tag command note action in Visual mode ~ |v_K| K run 'keywordprg' on the highlighted area |v_O| O move horizontally to other corner of area |v_P| P replace highlighted area with register - contents; unnamed register is unchanged + contents; registers are unchanged Q does not start Ex mode |v_R| R 2 delete the highlighted lines and start insert diff --git a/runtime/doc/visual.txt b/runtime/doc/visual.txt index 4d5366a41a..193c70e70a 100644 --- a/runtime/doc/visual.txt +++ b/runtime/doc/visual.txt @@ -255,7 +255,7 @@ Additionally the following commands can be used: X delete (2) |v_X| Y yank (2) |v_Y| p put |v_p| - P put without unnamed register overwrite |v_P| + P put without overwriting registers |v_P| J join (1) |v_J| U make uppercase |v_U| u make lowercase |v_u| diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index 8db215829f..6666b3c044 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -383,8 +383,14 @@ function M.rename(new_name, options) ) end + -- Clients must at least support rename, prepareRename is optional + clients = vim.tbl_filter( + function(client) return client.supports_method("textDocument/rename") end, + clients + ) + if #clients == 0 then - vim.notify("[LSP] Rename request failed, no matching language servers.") + vim.notify("[LSP] Rename, no matching language servers with rename capability.") end local win = vim.api.nvim_get_current_win() @@ -459,7 +465,8 @@ function M.rename(new_name, options) rename(input) end) end, bufnr) - elseif client.supports_method("textDocument/rename") then + else + assert(client.supports_method("textDocument/rename"), 'Client must support textDocument/rename') if new_name then rename(new_name) return @@ -475,8 +482,6 @@ function M.rename(new_name, options) end rename(input) end) - else - vim.notify('Client ' .. client.id .. '/' .. client.name .. ' has no rename capability') end end diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 2cf1bda45f..e6f70033d0 100755 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -157,7 +157,6 @@ list(REMOVE_ITEM NVIM_SOURCES ${to_remove}) # Legacy files that do not yet pass -Wconversion. set(CONV_SOURCES - edit.c eval.c ex_cmds.c fileio.c diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index 698b2d06fb..d3675a3c40 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -802,10 +802,15 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err) // Parse command line exarg_T ea; CmdParseInfo cmdinfo; - char_u *cmdline = (char_u *)string_to_cstr(str); + char *cmdline = string_to_cstr(str); + char *errormsg = NULL; - if (!parse_cmdline(cmdline, &ea, &cmdinfo)) { - api_set_error(err, kErrorTypeException, "Error while parsing command line"); + if (!parse_cmdline(cmdline, &ea, &cmdinfo, &errormsg)) { + if (errormsg != NULL) { + api_set_error(err, kErrorTypeException, "Error while parsing command line: %s", errormsg); + } else { + api_set_error(err, kErrorTypeException, "Error while parsing command line"); + } goto end; } @@ -854,7 +859,7 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err) ADD(range, INTEGER_OBJ(ea.line1)); } ADD(range, INTEGER_OBJ(ea.line2)); - PUT(result, "range", ARRAY_OBJ(range));; + PUT(result, "range", ARRAY_OBJ(range)); } else { PUT(result, "range", ARRAY_OBJ(ARRAY_DICT_INIT)); } diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c index 3e2d04b3a2..49e3a03dac 100644 --- a/src/nvim/buffer_updates.c +++ b/src/nvim/buffer_updates.c @@ -299,7 +299,7 @@ void buf_updates_send_changes(buf_T *buf, linenr_T firstline, int64_t num_added, kv_size(buf->update_callbacks) = j; } -void buf_updates_send_splice(buf_T *buf, int start_row, colnr_T start_col, bcount_t start_byte, +void buf_updates_send_splice(buf_T *buf, linenr_T start_row, colnr_T start_col, bcount_t start_byte, int old_row, colnr_T old_col, bcount_t old_byte, int new_row, colnr_T new_col, bcount_t new_byte) { diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 593c395661..ab80f09228 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1793,7 +1793,6 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang int last_vcol; int insstart_less; // reduction for Insstart.col int new_cursor_col; - int i; char_u *ptr; int save_p_list; int start_col; @@ -1906,10 +1905,10 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang */ if (vcol != (int)curwin->w_virtcol) { curwin->w_cursor.col = (colnr_T)new_cursor_col; - i = (int)curwin->w_virtcol - vcol; + size_t i = (size_t)(curwin->w_virtcol - vcol); ptr = xmallocz(i); memset(ptr, ' ', i); - new_cursor_col += i; + new_cursor_col += (int)i; ins_str(ptr); xfree(ptr); } @@ -2289,7 +2288,7 @@ int ins_compl_add_infercase(char_u *str_arg, int len, bool icase, char_u *fname, ? actual_len : actual_compl_length; // Allocate wide character array for the completion and fill it. - int *const wca = xmalloc(actual_len * sizeof(*wca)); + int *const wca = xmalloc((size_t)actual_len * sizeof(*wca)); { const char_u *p = str; for (i = 0; i < actual_len; i++) { @@ -2449,7 +2448,7 @@ static int ins_compl_add(char_u *const str, int len, char_u *const fname, if (flags & CP_ORIGINAL_TEXT) { match->cp_number = 0; } - match->cp_str = vim_strnsave(str, len); + match->cp_str = vim_strnsave(str, (size_t)len); // match-fname is: // - compl_curr_match->cp_fname if it is a string equal to fname. @@ -2682,7 +2681,7 @@ void set_completion(colnr_T startcol, list_T *list) compl_length = (int)curwin->w_cursor.col - (int)startcol; // compl_pattern doesn't need to be set compl_orig_text = vim_strnsave(get_cursor_line_ptr() + compl_col, - compl_length); + (size_t)compl_length); if (p_ic) { flags |= CP_ICASE; } @@ -2840,7 +2839,7 @@ void ins_compl_show_pum(void) do { if ((compl->cp_flags & CP_ORIGINAL_TEXT) == 0 && (compl_leader == NULL - || ins_compl_equal(compl, compl_leader, lead_len))) { + || ins_compl_equal(compl, compl_leader, (size_t)lead_len))) { compl_match_arraysize++; } compl = compl->cp_next; @@ -2850,9 +2849,9 @@ void ins_compl_show_pum(void) } assert(compl_match_arraysize >= 0); - compl_match_array = xcalloc(compl_match_arraysize, sizeof(pumitem_T)); - /* If the current match is the original text don't find the first - * match after it, don't highlight anything. */ + compl_match_array = xcalloc((size_t)compl_match_arraysize, sizeof(pumitem_T)); + // If the current match is the original text don't find the first + // match after it, don't highlight anything. if (compl_shown_match->cp_flags & CP_ORIGINAL_TEXT) { shown_match_ok = true; } @@ -2862,7 +2861,7 @@ void ins_compl_show_pum(void) do { if ((compl->cp_flags & CP_ORIGINAL_TEXT) == 0 && (compl_leader == NULL - || ins_compl_equal(compl, compl_leader, lead_len))) { + || ins_compl_equal(compl, compl_leader, (size_t)lead_len))) { if (!shown_match_ok) { if (compl == compl_shown_match || did_find_shown_match) { /* This item is the shown match or this is the @@ -3429,7 +3428,7 @@ static int ins_compl_bs(void) line = get_cursor_line_ptr(); xfree(compl_leader); - compl_leader = vim_strnsave(line + compl_col, (int)p_off - compl_col); + compl_leader = vim_strnsave(line + compl_col, (size_t)(p_off - (ptrdiff_t)compl_col)); ins_compl_new_leader(); if (compl_shown_match != NULL) { // Make sure current match is not a hidden item. @@ -3518,7 +3517,7 @@ static void ins_compl_addleader(int c) utf_char2bytes(c, buf); buf[cc] = NUL; - ins_char_bytes(buf, cc); + ins_char_bytes(buf, (size_t)cc); } else { ins_char(c); } @@ -3530,7 +3529,7 @@ static void ins_compl_addleader(int c) xfree(compl_leader); compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col, - curwin->w_cursor.col - compl_col); + (size_t)(curwin->w_cursor.col - compl_col)); ins_compl_new_leader(); } @@ -3590,8 +3589,7 @@ static void ins_compl_addfrommatch(void) for (cp = compl_shown_match->cp_next; cp != NULL && cp != compl_first_match; cp = cp->cp_next) { if (compl_leader == NULL - || ins_compl_equal(cp, compl_leader, - (int)STRLEN(compl_leader))) { + || ins_compl_equal(cp, compl_leader, STRLEN(compl_leader))) { p = cp->cp_str; break; } @@ -4753,12 +4751,10 @@ static int ins_compl_next(int allow_get_expansion, int count, int insert_match, /* If we didn't find it searching forward, and compl_shows_dir is * backward, find the last match. */ if (compl_shows_dir == BACKWARD - && !ins_compl_equal(compl_shown_match, - compl_leader, (int)STRLEN(compl_leader)) + && !ins_compl_equal(compl_shown_match, compl_leader, STRLEN(compl_leader)) && (compl_shown_match->cp_next == NULL || compl_shown_match->cp_next == compl_first_match)) { - while (!ins_compl_equal(compl_shown_match, - compl_leader, (int)STRLEN(compl_leader)) + while (!ins_compl_equal(compl_shown_match, compl_leader, STRLEN(compl_leader)) && compl_shown_match->cp_prev != NULL && compl_shown_match->cp_prev != compl_first_match) { compl_shown_match = compl_shown_match->cp_prev; @@ -5183,7 +5179,7 @@ static int ins_complete(int c, bool enable_pum) if (p_ic) { compl_pattern = str_foldcase(line + compl_col, compl_length, NULL, 0); } else { - compl_pattern = vim_strnsave(line + compl_col, compl_length); + compl_pattern = vim_strnsave(line + compl_col, (size_t)compl_length); } } else if (compl_cont_status & CONT_ADDING) { char_u *prefix = (char_u *)"\\<"; @@ -5247,7 +5243,7 @@ static int ins_complete(int c, bool enable_pum) if (p_ic) { compl_pattern = str_foldcase(line + compl_col, compl_length, NULL, 0); } else { - compl_pattern = vim_strnsave(line + compl_col, compl_length); + compl_pattern = vim_strnsave(line + compl_col, (size_t)compl_length); } } else if (ctrl_x_mode == CTRL_X_FILES) { // Go back to just before the first filename character. @@ -5267,9 +5263,9 @@ static int ins_complete(int c, bool enable_pum) compl_col += startcol; compl_length = (int)curs_col - startcol; - compl_pattern = addstar(line + compl_col, compl_length, EXPAND_FILES); + compl_pattern = addstar(line + compl_col, (size_t)compl_length, EXPAND_FILES); } else if (ctrl_x_mode == CTRL_X_CMDLINE || ctrl_x_mode == CTRL_X_CMDLINE_CTRL_X) { - compl_pattern = vim_strnsave(line, curs_col); + compl_pattern = vim_strnsave(line, (size_t)curs_col); set_cmd_context(&compl_xp, compl_pattern, (int)STRLEN(compl_pattern), curs_col, false); if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL @@ -5311,7 +5307,7 @@ static int ins_complete(int c, bool enable_pum) pos = curwin->w_cursor; curwin_save = curwin; curbuf_save = curbuf; - int col = call_func_retnr((char *)funcname, 2, args); + colnr_T col = (colnr_T)call_func_retnr((char *)funcname, 2, args); State = save_State; if (curwin_save != curwin || curbuf_save != curbuf) { @@ -5356,7 +5352,7 @@ static int ins_complete(int c, bool enable_pum) * it may have become invalid. */ line = ml_get(curwin->w_cursor.lnum); compl_length = curs_col - compl_col; - compl_pattern = vim_strnsave(line + compl_col, compl_length); + compl_pattern = vim_strnsave(line + compl_col, (size_t)compl_length); } else if (ctrl_x_mode == CTRL_X_SPELL) { if (spell_bad_len > 0) { assert(spell_bad_len <= INT_MAX); @@ -5373,7 +5369,7 @@ static int ins_complete(int c, bool enable_pum) } // Need to obtain "line" again, it may have become invalid. line = ml_get(curwin->w_cursor.lnum); - compl_pattern = vim_strnsave(line + compl_col, compl_length); + compl_pattern = vim_strnsave(line + compl_col, (size_t)compl_length); } else { internal_error("ins_complete()"); return FAIL; @@ -5410,7 +5406,7 @@ static int ins_complete(int c, bool enable_pum) // Always add completion for the original text. xfree(compl_orig_text); - compl_orig_text = vim_strnsave(line + compl_col, compl_length); + compl_orig_text = vim_strnsave(line + compl_col, (size_t)compl_length); if (p_ic) { flags |= CP_ICASE; } @@ -5840,7 +5836,6 @@ void insertchar(int c, int flags, int second_indent) if (did_ai && c == end_comment_pending) { char_u *line; char_u lead_end[COM_MAX_LEN]; // end-comment string - int middle_len, end_len; int i; /* @@ -5853,7 +5848,7 @@ void insertchar(int c, int flags, int second_indent) while (*p && p[-1] != ':') { // find end of middle flags p++; } - middle_len = copy_option_part(&p, lead_end, COM_MAX_LEN, ","); + int middle_len = (int)copy_option_part(&p, lead_end, COM_MAX_LEN, ","); // Don't count trailing white space for middle_len while (middle_len > 0 && ascii_iswhite(lead_end[middle_len - 1])) { middle_len--; @@ -5863,7 +5858,7 @@ void insertchar(int c, int flags, int second_indent) while (*p && p[-1] != ':') { // find end of end flags p++; } - end_len = copy_option_part(&p, lead_end, COM_MAX_LEN, ","); + int end_len = (int)copy_option_part(&p, lead_end, COM_MAX_LEN, ","); // Skip white space before the cursor i = curwin->w_cursor.col; @@ -5880,7 +5875,7 @@ void insertchar(int c, int flags, int second_indent) // Insert the end-comment string, except for the last // character, which will get inserted as normal later. - ins_bytes_len(lead_end, end_len - 1); + ins_bytes_len(lead_end, (size_t)(end_len - 1)); } } } @@ -5912,7 +5907,7 @@ void insertchar(int c, int flags, int second_indent) int i; colnr_T virtcol = 0; - buf[0] = c; + buf[0] = (char_u)c; i = 1; if (textwidth > 0) { virtcol = get_nolist_virtcol(); @@ -5934,7 +5929,7 @@ void insertchar(int c, int flags, int second_indent) if (p_hkmap && KeyTyped) { c = hkmap(c); // Hebrew mode mapping } - buf[i++] = c; + buf[i++] = (char_u)c; } do_digraph(-1); // clear digraphs @@ -5958,7 +5953,7 @@ void insertchar(int c, int flags, int second_indent) utf_char2bytes(c, buf); buf[cc] = NUL; - ins_char_bytes(buf, cc); + ins_char_bytes(buf, (size_t)cc); AppendCharToRedobuff(c); } else { ins_char(c); @@ -6372,7 +6367,7 @@ static void internal_format(int textwidth, int second_indent, int flags, int for } if (save_char != NUL) { // put back space after cursor - pchar_cursor(save_char); + pchar_cursor((char_u)save_char); } curwin->w_p_lbr = has_lbr; @@ -6475,7 +6470,7 @@ void auto_format(bool trailblank, bool prev_line) new = get_cursor_line_ptr(); len = (colnr_T)STRLEN(new); if (curwin->w_cursor.col == len) { - pnew = vim_strnsave(new, len + 2); + pnew = vim_strnsave(new, (size_t)len + 2); pnew[len] = ' '; pnew[len + 1] = NUL; ml_replace(curwin->w_cursor.lnum, (char *)pnew, false); @@ -6529,11 +6524,11 @@ static void check_auto_format(bool end_insert) /// @param ff force formatting (for "gq" command) int comp_textwidth(bool ff) { - int textwidth = curbuf->b_p_tw; + int textwidth = (int)curbuf->b_p_tw; if (textwidth == 0 && curbuf->b_p_wm) { // The width is the window width minus 'wrapmargin' minus all the // things that add to the margin. - textwidth = curwin->w_width_inner - curbuf->b_p_wm; + textwidth = curwin->w_width_inner - (int)curbuf->b_p_wm; if (cmdwin_type != 0) { textwidth -= 1; } @@ -6857,7 +6852,7 @@ char_u *add_char2buf(int c, char_u *s) *s++ = KS_SPECIAL; *s++ = KE_FILLER; } else { - *s++ = c; + *s++ = (char_u)c; } } return s; @@ -7237,11 +7232,11 @@ void replace_push(int c) if (replace_stack_len <= replace_stack_nr) { replace_stack_len += 50; - replace_stack = xrealloc(replace_stack, replace_stack_len); + replace_stack = xrealloc(replace_stack, (size_t)replace_stack_len); } char_u *p = replace_stack + replace_stack_nr - replace_offset; if (replace_offset) { - memmove(p + 1, p, replace_offset); + memmove(p + 1, p, (size_t)replace_offset); } *p = (char_u)c; ++replace_stack_nr; @@ -7277,9 +7272,7 @@ static int replace_pop(void) /// @param off offset for which NUL to remove static void replace_join(int off) { - int i; - - for (i = replace_stack_nr; --i >= 0;) { + for (ssize_t i = replace_stack_nr; --i >= 0;) { if (replace_stack[i] == NUL && off-- <= 0) { --replace_stack_nr; memmove(replace_stack + i, replace_stack + i + 1, @@ -7318,11 +7311,11 @@ static void mb_replace_pop_ins(int cc) int c; if ((n = MB_BYTE2LEN(cc)) > 1) { - buf[0] = cc; - for (i = 1; i < n; ++i) { - buf[i] = replace_pop(); + buf[0] = (char_u)cc; + for (i = 1; i < n; i++) { + buf[i] = (char_u)replace_pop(); } - ins_bytes_len(buf, n); + ins_bytes_len(buf, (size_t)n); } else { ins_char(cc); } @@ -7339,13 +7332,13 @@ static void mb_replace_pop_ins(int cc) break; } - buf[0] = c; + buf[0] = (char_u)c; assert(n > 1); for (i = 1; i < n; i++) { - buf[i] = replace_pop(); + buf[i] = (char_u)replace_pop(); } if (utf_iscomposing(utf_ptr2char(buf))) { - ins_bytes_len(buf, n); + ins_bytes_len(buf, (size_t)n); } else { // Not a composing char, put it back. for (i = n - 1; i >= 0; i--) { @@ -9143,8 +9136,7 @@ static bool ins_tab(void) // Insert each char in saved_line from changed_col to // ptr-cursor - ins_bytes_len(saved_line + change_col, - cursor->col - change_col); + ins_bytes_len(saved_line + change_col, (size_t)(cursor->col - change_col)); } } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d910b47c57..548dd96444 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6632,7 +6632,7 @@ void get_user_input(const typval_T *const argvars, typval_T *const rettv, const // input() with a third argument: completion const int xp_namelen = (int)strlen(xp_name); - uint32_t argt; + uint32_t argt = 0; if (parse_compl_arg(xp_name, xp_namelen, &xp_type, &argt, &xp_arg) == FAIL) { return; diff --git a/src/nvim/eval.h b/src/nvim/eval.h index c81b31aba9..101f6d9176 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -185,8 +185,8 @@ typedef enum { kMPArray, kMPMap, kMPExt, -#define LAST_MSGPACK_TYPE kMPExt } MessagePackType; +#define LAST_MSGPACK_TYPE kMPExt /// Array mapping values from MessagePackType to corresponding list pointers extern const list_T *eval_msgpack_type_lists[LAST_MSGPACK_TYPE + 1]; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 95775d68d4..116264b4c1 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1359,12 +1359,17 @@ static int parse_count(exarg_T *eap, char **errormsg) /// Parse command line and return information about the first command. /// +/// @param cmdline Command line string +/// @param[out] eap Ex command arguments +/// @param[out] cmdinfo Command parse information +/// @param[out] errormsg Error message, if any +/// /// @return Success or failure -bool parse_cmdline(char_u *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo) +bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **errormsg) { - char *errormsg = NULL; char *cmd; char *p; + char *after_modifier = NULL; cmdmod_T save_cmdmod = cmdmod; // Initialize cmdinfo @@ -1374,15 +1379,17 @@ bool parse_cmdline(char_u *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo) memset(eap, 0, sizeof(*eap)); eap->line1 = 1; eap->line2 = 1; - eap->cmd = (char *)cmdline; - eap->cmdlinep = (char **)&cmdline; + eap->cmd = cmdline; + eap->cmdlinep = &cmdline; eap->getline = NULL; eap->cookie = NULL; // Parse command modifiers - if (parse_command_modifiers(eap, &errormsg, false) == FAIL) { + if (parse_command_modifiers(eap, errormsg, false) == FAIL) { return false; } + after_modifier = eap->cmd; + // Revert the side-effects of `parse_command_modifiers` if (eap->save_msg_silent != -1) { cmdinfo->silent = !!msg_silent; @@ -1422,7 +1429,7 @@ bool parse_cmdline(char_u *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo) // Set command attribute type and parse command range set_cmd_addr_type(eap, (char_u *)p); eap->cmd = cmd; - if (parse_cmd_address(eap, &errormsg, false) == FAIL) { + if (parse_cmd_address(eap, errormsg, false) == FAIL) { return false; } @@ -1434,6 +1441,11 @@ bool parse_cmdline(char_u *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo) } // Fail if command is invalid if (eap->cmdidx == CMD_SIZE) { + STRCPY(IObuff, _("E492: Not an editor command")); + // If the modifier was parsed OK the error must be in the following command + char *cmdname = after_modifier ? after_modifier : cmdline; + append_command(cmdname); + *errormsg = (char *)IObuff; return false; } @@ -1472,10 +1484,12 @@ bool parse_cmdline(char_u *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo) } // Fail if command doesn't support bang but is used with a bang if (!(eap->argt & EX_BANG) && eap->forceit) { + *errormsg = _(e_nobang); return false; } // Fail if command doesn't support a range but it is given a range if (!(eap->argt & EX_RANGE) && eap->addr_count > 0) { + *errormsg = _(e_norange); return false; } // Set default range for command if required @@ -1485,7 +1499,7 @@ bool parse_cmdline(char_u *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo) // Parse register and count parse_register(eap); - if (parse_count(eap, NULL) == FAIL) { + if (parse_count(eap, errormsg) == FAIL) { return false; } diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index 1b0e2c8590..09ea2be4fe 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -417,7 +417,7 @@ static void u_extmark_set(buf_T *buf, uint64_t mark, int row, colnr_T col) /// /// useful when we cannot simply reverse the operation. This will do nothing on /// redo, enforces correct position when undo. -void u_extmark_copy(buf_T *buf, int l_row, colnr_T l_col, int u_row, colnr_T u_col) +void u_extmark_copy(buf_T *buf, linenr_T l_row, colnr_T l_col, linenr_T u_row, colnr_T u_col) { u_header_T *uhp = u_force_get_undo_header(buf); if (!uhp) { @@ -427,7 +427,7 @@ void u_extmark_copy(buf_T *buf, int l_row, colnr_T l_col, int u_row, colnr_T u_c ExtmarkUndoObject undo; MarkTreeIter itr[1] = { 0 }; - marktree_itr_get(buf->b_marktree, l_row, l_col, itr); + marktree_itr_get(buf->b_marktree, (int32_t)l_row, l_col, itr); while (true) { mtkey_t mark = marktree_itr_current(itr); if (mark.pos.row < 0 @@ -553,7 +553,7 @@ void extmark_adjust(buf_T *buf, linenr_T line1, linenr_T line2, long amount, lon // the end column of the new region. // @param new_byte Byte extent of the new region. // @param undo -void extmark_splice(buf_T *buf, int start_row, colnr_T start_col, int old_row, colnr_T old_col, +void extmark_splice(buf_T *buf, linenr_T start_row, colnr_T start_col, int old_row, colnr_T old_col, bcount_t old_byte, int new_row, colnr_T new_col, bcount_t new_byte, ExtmarkOp undo) { @@ -573,7 +573,7 @@ void extmark_splice(buf_T *buf, int start_row, colnr_T start_col, int old_row, c undo); } -void extmark_splice_impl(buf_T *buf, int start_row, colnr_T start_col, bcount_t start_byte, +void extmark_splice_impl(buf_T *buf, linenr_T start_row, colnr_T start_col, bcount_t start_byte, int old_row, colnr_T old_col, bcount_t old_byte, int new_row, colnr_T new_col, bcount_t new_byte, ExtmarkOp undo) { @@ -588,13 +588,13 @@ void extmark_splice_impl(buf_T *buf, int start_row, colnr_T start_col, bcount_t // beginning and right-gravity at the end need not be preserved. // Also be smart about marks that already have been saved (important for // merge!) - int end_row = start_row + old_row; + linenr_T end_row = start_row + old_row; int end_col = (old_row ? 0 : start_col) + old_col; u_extmark_copy(buf, start_row, start_col, end_row, end_col); } - marktree_splice(buf->b_marktree, start_row, start_col, + marktree_splice(buf->b_marktree, (int32_t)start_row, start_col, old_row, old_col, new_row, new_col); @@ -656,7 +656,7 @@ void extmark_splice_impl(buf_T *buf, int start_row, colnr_T start_col, bcount_t } } -void extmark_splice_cols(buf_T *buf, int start_row, colnr_T start_col, colnr_T old_col, +void extmark_splice_cols(buf_T *buf, linenr_T start_row, colnr_T start_col, colnr_T old_col, colnr_T new_col, ExtmarkOp undo) { extmark_splice(buf, start_row, start_col, diff --git a/src/nvim/extmark.h b/src/nvim/extmark.h index b856a1148f..84d1e8d03b 100644 --- a/src/nvim/extmark.h +++ b/src/nvim/extmark.h @@ -29,7 +29,7 @@ typedef ptrdiff_t bcount_t; // delete the columns between mincol and endcol typedef struct { - int start_row; + linenr_T start_row; colnr_T start_col; int old_row; colnr_T old_col; diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 3ae0d32d8f..620af9444c 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -606,7 +606,7 @@ EXTERN pos_T Insstart; // This is where the latest EXTERN pos_T Insstart_orig; // Stuff for VREPLACE mode. -EXTERN int orig_line_count INIT(= 0); // Line count when "gR" started +EXTERN linenr_T orig_line_count INIT(= 0); // Line count when "gR" started EXTERN int vr_lines_changed INIT(= 0); // #Lines changed by "gR" so far // increase around internal delete/replace diff --git a/src/nvim/lib/kbtree.h b/src/nvim/lib/kbtree.h index aca96c9a7a..2edec527ff 100644 --- a/src/nvim/lib/kbtree.h +++ b/src/nvim/lib/kbtree.h @@ -103,11 +103,11 @@ int mid = (begin + end) >> 1; \ if (__cmp(__KB_KEY(key_t, x)[mid], *k) < 0) begin = mid + 1; \ else end = mid; \ - } \ - if (begin == x->n) { *rr = 1; return x->n - 1; } \ - if ((*rr = __cmp(*k, __KB_KEY(key_t, x)[begin])) < 0) --begin; \ - return begin; \ - } + } \ + if (begin == x->n) { *rr = 1; return x->n - 1; } \ + if ((*rr = __cmp(*k, __KB_KEY(key_t, x)[begin])) < 0) --begin; \ + return begin; \ + } #define __KB_GET(name, key_t, kbnode_t) \ static key_t *kb_getp_##name(kbtree_##name##_t *b, key_t * __restrict k) \ @@ -195,34 +195,34 @@ if (__KB_PTR(b, x)[i]->n == 2 * T - 1) { \ __kb_split_##name(b, x, i, __KB_PTR(b, x)[i]); \ if (__cmp(*k, __KB_KEY(key_t, x)[i]) > 0) ++i; \ - } \ - ret = __kb_putp_aux_##name(b, __KB_PTR(b, x)[i], k); \ } \ - return ret; \ + ret = __kb_putp_aux_##name(b, __KB_PTR(b, x)[i], k); \ } \ - static inline key_t *kb_putp_##name(kbtree_##name##_t *b, key_t * __restrict k) \ - { \ - if (!b->root) { \ - b->root = (kbnode_t *)xcalloc(1, ILEN); \ - ++b->n_nodes; \ - } \ - kbnode_t *r, *s; \ - ++b->n_keys; \ - r = b->root; \ - if (r->n == 2 * T - 1) { \ - ++b->n_nodes; \ - s = (kbnode_t *)xcalloc(1, ILEN); \ - b->root = s; s->is_internal = 1; s->n = 0; \ - __KB_PTR(b, s)[0] = r; \ - __kb_split_##name(b, s, 0, r); \ - r = s; \ - } \ - return __kb_putp_aux_##name(b, r, k); \ + return ret; \ + } \ + static inline key_t *kb_putp_##name(kbtree_##name##_t *b, key_t * __restrict k) \ + { \ + if (!b->root) { \ + b->root = (kbnode_t *)xcalloc(1, ILEN); \ + ++b->n_nodes; \ } \ - static inline void kb_put_##name(kbtree_##name##_t *b, key_t k) \ - { \ - kb_putp_##name(b, &k); \ - } + kbnode_t *r, *s; \ + ++b->n_keys; \ + r = b->root; \ + if (r->n == 2 * T - 1) { \ + ++b->n_nodes; \ + s = (kbnode_t *)xcalloc(1, ILEN); \ + b->root = s; s->is_internal = 1; s->n = 0; \ + __KB_PTR(b, s)[0] = r; \ + __kb_split_##name(b, s, 0, r); \ + r = s; \ + } \ + return __kb_putp_aux_##name(b, r, k); \ + } \ + static inline void kb_put_##name(kbtree_##name##_t *b, key_t k) \ + { \ + kb_putp_##name(b, &k); \ + } #define __KB_DEL(name, key_t, kbnode_t, T) \ @@ -380,58 +380,58 @@ } \ --itr->p; \ if (itr->p->x && itr->p->i < itr->p->x->n) return 1; \ + } \ + } \ + static inline int kb_itr_prev_##name(kbtree_##name##_t *b, kbitr_##name##_t *itr) \ + { \ + if (itr->p == NULL) return 0; \ + for (;;) { \ + while (itr->p->x && itr->p->i >= 0) { \ + itr->p[1].x = itr->p->x->is_internal? __KB_PTR(b, itr->p->x)[itr->p->i] : 0; \ + itr->p[1].i = itr->p[1].x ? itr->p[1].x->n : -1; \ + ++itr->p; \ } \ + if (itr->p == itr->stack) { \ + itr->p = NULL; \ + return 0; \ } \ - static inline int kb_itr_prev_##name(kbtree_##name##_t *b, kbitr_##name##_t *itr) \ - { \ - if (itr->p == NULL) return 0; \ - for (;;) { \ - while (itr->p->x && itr->p->i >= 0) { \ - itr->p[1].x = itr->p->x->is_internal? __KB_PTR(b, itr->p->x)[itr->p->i] : 0; \ - itr->p[1].i = itr->p[1].x ? itr->p[1].x->n : -1; \ - ++itr->p; \ - } \ - if (itr->p == itr->stack) { \ - itr->p = NULL; \ - return 0; \ - } \ - --itr->p; \ - --itr->p->i; \ - if (itr->p->x && itr->p->i >= 0) return 1; \ - } \ - } \ - static inline int kb_itr_getp_##name(kbtree_##name##_t *b, key_t * __restrict k, \ - kbitr_##name##_t *itr) \ - { \ - if (b->n_keys == 0) { \ - itr->p = NULL; \ - return 0; \ - } \ - int i, r = 0; \ - itr->p = itr->stack; \ - itr->p->x = b->root; \ - while (itr->p->x) { \ - i = __kb_getp_aux_##name(itr->p->x, k, &r); \ - itr->p->i = i; \ - if (i >= 0 && r == 0) return 1; \ - ++itr->p->i; \ - assert(itr->p->i <= 21); \ - itr->p[1].x = itr->p->x->is_internal? __KB_PTR(b, itr->p->x)[i + 1] : 0; \ - ++itr->p; \ - } \ - itr->p->i = 0; \ - return 0; \ - } \ - static inline int kb_itr_get_##name(kbtree_##name##_t *b, key_t k, kbitr_##name##_t *itr) \ - { \ - return kb_itr_getp_##name(b, &k, itr); \ - } \ - static inline void kb_del_itr_##name(kbtree_##name##_t *b, kbitr_##name##_t *itr) \ - { \ - key_t k = kb_itr_key(itr); \ - kb_delp_##name(b, &k); \ - kb_itr_getp_##name(b, &k, itr); \ - } + --itr->p; \ + --itr->p->i; \ + if (itr->p->x && itr->p->i >= 0) return 1; \ + } \ + } \ + static inline int kb_itr_getp_##name(kbtree_##name##_t *b, key_t * __restrict k, \ + kbitr_##name##_t *itr) \ + { \ + if (b->n_keys == 0) { \ + itr->p = NULL; \ + return 0; \ + } \ + int i, r = 0; \ + itr->p = itr->stack; \ + itr->p->x = b->root; \ + while (itr->p->x) { \ + i = __kb_getp_aux_##name(itr->p->x, k, &r); \ + itr->p->i = i; \ + if (i >= 0 && r == 0) return 1; \ + ++itr->p->i; \ + assert(itr->p->i <= 21); \ + itr->p[1].x = itr->p->x->is_internal? __KB_PTR(b, itr->p->x)[i + 1] : 0; \ + ++itr->p; \ + } \ + itr->p->i = 0; \ + return 0; \ + } \ + static inline int kb_itr_get_##name(kbtree_##name##_t *b, key_t k, kbitr_##name##_t *itr) \ + { \ + return kb_itr_getp_##name(b, &k, itr); \ + } \ + static inline void kb_del_itr_##name(kbtree_##name##_t *b, kbitr_##name##_t *itr) \ + { \ + key_t k = kb_itr_key(itr); \ + kb_delp_##name(b, &k); \ + kb_itr_getp_##name(b, &k, itr); \ + } #define KBTREE_INIT(name, key_t, __cmp, T) \ KBTREE_INIT_IMPL(name, key_t, kbnode_##name##_t, __cmp, T, \ diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c index ff31567bf5..fb2fa6bc7d 100644 --- a/src/nvim/marktree.c +++ b/src/nvim/marktree.c @@ -583,7 +583,7 @@ void marktree_move(MarkTree *b, MarkTreeIter *itr, int row, int col) // itr functions // TODO(bfredl): static inline? -bool marktree_itr_get(MarkTree *b, int row, int col, MarkTreeIter *itr) +bool marktree_itr_get(MarkTree *b, int32_t row, int col, MarkTreeIter *itr) { return marktree_itr_get_ext(b, (mtpos_t){ row, col }, itr, false, false, NULL); @@ -832,7 +832,7 @@ static void itr_swap(MarkTreeIter *itr1, MarkTreeIter *itr2) rawkey(itr2).pos = key2.pos; } -bool marktree_splice(MarkTree *b, int start_line, int start_col, int old_extent_line, +bool marktree_splice(MarkTree *b, int32_t start_line, int start_col, int old_extent_line, int old_extent_col, int new_extent_line, int new_extent_col) { mtpos_t start = { start_line, start_col }; diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 2eb3c4be72..81c95ec77f 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -7108,7 +7108,7 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) // overwrites if the old contents is being put. was_visual = true; regname = cap->oap->regname; - bool save_unnamed = cap->cmdchar == 'P'; + bool keep_registers = cap->cmdchar == 'P'; // '+' and '*' could be the same selection bool clipoverwrite = (regname == '+' || regname == '*') && (cb_flags & CB_UNNAMEDMASK); if (regname == 0 || regname == '"' || clipoverwrite @@ -7123,23 +7123,15 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) // do_put(), which requires the visual selection to still be active. if (!VIsual_active || VIsual_mode == 'V' || regname != '.') { // Now delete the selected text. Avoid messages here. - yankreg_T *old_y_previous; - if (save_unnamed) { - old_y_previous = get_y_previous(); - } cap->cmdchar = 'd'; cap->nchar = NUL; - cap->oap->regname = NUL; + cap->oap->regname = keep_registers ? '_' : NUL; msg_silent++; nv_operator(cap); do_pending_operator(cap, 0, false); empty = (curbuf->b_ml.ml_flags & ML_EMPTY); msg_silent--; - if (save_unnamed) { - set_y_previous(old_y_previous); - } - // delete PUT_LINE_BACKWARD; cap->oap->regname = regname; } diff --git a/src/nvim/shada.c b/src/nvim/shada.c index e89efe1cbc..05df0e590b 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -151,8 +151,8 @@ typedef enum { kSDItemBufferList = 9, ///< Buffer list. kSDItemLocalMark = 10, ///< Buffer-local mark. kSDItemChange = 11, ///< Item from buffer change list. -#define SHADA_LAST_ENTRY ((uint64_t)kSDItemChange) } ShadaEntryType; +#define SHADA_LAST_ENTRY ((uint64_t)kSDItemChange) /// Possible results when reading ShaDa file typedef enum { diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 848044ee7c..a897228d6b 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -408,7 +408,7 @@ size_t xstrnlen(const char *s, size_t n) if (end == NULL) { return n; } - return end - s; + return (size_t)(end - s); } #endif diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index ae8f9ba70b..2b88deb813 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -1350,34 +1350,74 @@ func Test_visual_paste() call assert_equal('x', @-) call assert_equal('bazooxxf', getline(1)) - if has('clipboard') - " v_P does not overwrite unnamed register. + bwipe! +endfunc + +func Test_visual_paste_clipboard() + CheckFeature clipboard_working + + if has('gui') + " auto select feature breaks tests + set guioptions-=a + endif + + " v_P does not overwrite unnamed register. + call setline(1, ['xxxx']) + call setreg('"', 'foo') + call setreg('-', 'bar') + normal gg0vP + call assert_equal('foo', @") + call assert_equal('bar', @-) + call assert_equal('fooxxx', getline(1)) + normal $vP + call assert_equal('foo', @") + call assert_equal('bar', @-) + call assert_equal('fooxxfoo', getline(1)) + " Test with a different register as unnamed register. + call setline(2, ['baz']) + normal 2gg0"rD + call assert_equal('baz', @") + normal gg0vP + call assert_equal('baz', @") + call assert_equal('bar', @-) + call assert_equal('bazooxxfoo', getline(1)) + normal $vP + call assert_equal('baz', @") + call assert_equal('bar', @-) + call assert_equal('bazooxxfobaz', getline(1)) + + " Test for unnamed clipboard + set clipboard=unnamed + call setline(1, ['xxxx']) + call setreg('"', 'foo') + call setreg('-', 'bar') + call setreg('*', 'baz') + normal gg0vP + call assert_equal('foo', @") + call assert_equal('bar', @-) + call assert_equal('baz', @*) + call assert_equal('bazxxx', getline(1)) + + " Test for unnamedplus clipboard + if has('unnamedplus') + set clipboard=unnamedplus call setline(1, ['xxxx']) call setreg('"', 'foo') call setreg('-', 'bar') + call setreg('+', 'baz') normal gg0vP call assert_equal('foo', @") - call assert_equal('x', @-) - call assert_equal('fooxxx', getline(1)) - normal $vP - call assert_equal('foo', @") - call assert_equal('x', @-) - call assert_equal('fooxxfoo', getline(1)) - " Test with a different register as unnamed register. - call setline(2, ['baz']) - normal 2gg0"rD - call assert_equal('baz', @") - normal gg0vP - call assert_equal('baz', @") - call assert_equal('f', @-) - call assert_equal('bazooxxfoo', getline(1)) - normal $vP - call assert_equal('baz', @") - call assert_equal('o', @-) - call assert_equal('bazooxxfobaz', getline(1)) + call assert_equal('bar', @-) + call assert_equal('baz', @+) + call assert_equal('bazxxx', getline(1)) endif + set clipboard& + if has('gui') + set guioptions& + endif bwipe! endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/uncrustify.cfg b/src/uncrustify.cfg index 401e48d6e0..5f1165024a 100644 --- a/src/uncrustify.cfg +++ b/src/uncrustify.cfg @@ -1,4 +1,4 @@ -# Uncrustify-0.74.0_f +# Uncrustify-0.75.0_f # # General options @@ -127,6 +127,11 @@ sp_before_assign = ignore # ignore/add/remove/force/not_defined # Overrides sp_assign. sp_after_assign = ignore # ignore/add/remove/force/not_defined +# Add or remove space in 'enum {'. +# +# Default: add +sp_enum_brace = add # ignore/add/remove/force/not_defined + # Add or remove space in 'NS_ENUM ('. sp_enum_paren = ignore # ignore/add/remove/force/not_defined @@ -218,6 +223,10 @@ sp_after_ptr_star_trailing = ignore # ignore/add/remove/force/not_defined # in a function pointer definition. sp_ptr_star_func_var = ignore # ignore/add/remove/force/not_defined +# Add or remove space between the pointer star '*' and the name of the type +# in a function pointer type definition. +sp_ptr_star_func_type = ignore # ignore/add/remove/force/not_defined + # Add or remove space after a pointer star '*', if followed by an open # parenthesis, as in 'void* (*)()'. sp_ptr_star_paren = ignore # ignore/add/remove/force/not_defined @@ -252,6 +261,10 @@ sp_after_byref_func = ignore # ignore/add/remove/force/not_defined # prototype or function definition. sp_before_byref_func = ignore # ignore/add/remove/force/not_defined +# Add or remove space after a reference sign '&', if followed by an open +# parenthesis, as in 'char& (*)()'. +sp_byref_paren = ignore # ignore/add/remove/force/not_defined + # Add or remove space between type and word. In cases where total removal of # whitespace would be a syntax error, a value of 'remove' is treated the same # as 'force'. @@ -452,14 +465,17 @@ sp_between_mdatype_commas = ignore # ignore/add/remove/force/not_defined # Default: force sp_paren_comma = force # ignore/add/remove/force/not_defined +# Add or remove space between a type and ':'. +sp_type_colon = ignore # ignore/add/remove/force/not_defined + # Add or remove space after the variadic '...' when preceded by a # non-punctuator. -# The value REMOVE will be overriden with FORCE +# The value REMOVE will be overridden with FORCE sp_after_ellipsis = ignore # ignore/add/remove/force/not_defined # Add or remove space before the variadic '...' when preceded by a # non-punctuator. -# The value REMOVE will be overriden with FORCE +# The value REMOVE will be overridden with FORCE sp_before_ellipsis = ignore # ignore/add/remove/force/not_defined # Add or remove space between a type and '...'. @@ -468,9 +484,6 @@ sp_type_ellipsis = ignore # ignore/add/remove/force/not_defined # Add or remove space between a '*' and '...'. sp_ptr_type_ellipsis = ignore # ignore/add/remove/force/not_defined -# (D) Add or remove space between a type and '?'. -sp_type_question = ignore # ignore/add/remove/force/not_defined - # Add or remove space between ')' and '...'. sp_paren_ellipsis = ignore # ignore/add/remove/force/not_defined @@ -790,6 +803,10 @@ sp_d_array_colon = ignore # ignore/add/remove/force/not_defined # Default: remove sp_not = remove # ignore/add/remove/force/not_defined +# Add or remove space between two '!' (not) unary operators. +# If set to ignore, sp_not will be used. +sp_not_not = ignore # ignore/add/remove/force/not_defined + # Add or remove space after the '~' (invert) unary operator. # # Default: remove @@ -1044,15 +1061,21 @@ force_tab_after_define = false # true/false # Default: 8 indent_columns = 2 # unsigned number +# Whether to ignore indent for the first continuation line. Subsequent +# continuation lines will still be indented to match the first. +indent_ignore_first_continue = false # true/false + # The continuation indent. If non-zero, this overrides the indent of '(', '[' # and '=' continuation indents. Negative values are OK; negative value is # absolute and not increased for each '(' or '[' level. # # For FreeBSD, this is set to 4. +# Requires indent_ignore_first_continue=false. indent_continue = 0 # number # The continuation indent, only for class header line(s). If non-zero, this # overrides the indent of 'class' continuation indents. +# Requires indent_ignore_first_continue=false. indent_continue_class_head = 0 # unsigned number # Whether to indent empty lines (i.e. lines which contain only spaces before @@ -1128,16 +1151,23 @@ indent_namespace_level = 0 # unsigned number # indented. Requires indent_namespace=true. 0 means no limit. indent_namespace_limit = 0 # unsigned number +# Whether to indent only in inner namespaces (nested in other namespaces). +# Requires indent_namespace=true. +indent_namespace_inner_only = false # true/false + # Whether the 'extern "C"' body is indented. indent_extern = false # true/false # Whether the 'class' body is indented. indent_class = false # true/false +# Whether to ignore indent for the leading base class colon. +indent_ignore_before_class_colon = false # true/false + # Additional indent before the leading base class colon. # Negative values decrease indent down to the first column. -# Requires a newline break before colon (see pos_class_colon -# and nl_class_colon) +# Requires indent_ignore_before_class_colon=false and a newline break before +# the colon (see pos_class_colon and nl_class_colon) indent_before_class_colon = 0 # number # Whether to indent the stuff after a leading base class colon. @@ -1147,6 +1177,9 @@ indent_class_colon = false # true/false # colon. Requires indent_class_colon=true. indent_class_on_colon = false # true/false +# Whether to ignore indent for a leading class initializer colon. +indent_ignore_before_constr_colon = false # true/false + # Whether to indent the stuff after a leading class initializer colon. indent_constr_colon = false # true/false @@ -1177,9 +1210,12 @@ indent_var_def_blk = 0 # number # Whether to indent continued variable declarations instead of aligning. indent_var_def_cont = false # true/false -# Whether to indent continued shift expressions ('<<' and '>>') instead of -# aligning. Set align_left_shift=false when enabling this. -indent_shift = false # true/false +# How to indent continued shift expressions ('<<' and '>>'). +# Set align_left_shift=false when using this. +# 0: Align shift operators instead of indenting them (default) +# 1: Indent by one level +# -1: Preserve original indentation +indent_shift = 0 # number # Whether to force indentation of function definitions to start in column 1. indent_func_def_force_col1 = false # true/false @@ -1266,6 +1302,9 @@ indent_switch_case = 0 # unsigned number # Usually the same as indent_columns or indent_switch_case. indent_switch_body = 0 # unsigned number +# Whether to ignore indent for '{' following 'case'. +indent_ignore_case_brace = false # true/false + # Spaces to indent '{' from 'case'. By default, the brace will appear under # the 'c' in case. Usually set to 0 or indent_columns. Negative values are OK. # It might be wise to choose the same value for the option indent_switch_case. @@ -1334,10 +1373,11 @@ indent_paren_nl = false # true/false # How to indent a close parenthesis after a newline. # -# 0: Indent to body level (default) -# 1: Align under the open parenthesis -# 2: Indent to the brace level -indent_paren_close = 0 # unsigned number +# 0: Indent to body level (default) +# 1: Align under the open parenthesis +# 2: Indent to the brace level +# -1: Preserve original indentation +indent_paren_close = 0 # number # Whether to indent the open parenthesis of a function definition, # if the parenthesis is on its own line. @@ -1351,24 +1391,41 @@ indent_paren_after_func_decl = false # true/false # if the parenthesis is on its own line. indent_paren_after_func_call = true # true/false -# Whether to indent a comma when inside a brace. -# If true, aligns under the open brace. -indent_comma_brace = false # true/false +# How to indent a comma when inside braces. +# 0: Indent by one level (default) +# 1: Align under the open brace +# -1: Preserve original indentation +indent_comma_brace = 0 # number -# Whether to indent a comma when inside a parenthesis. -# If true, aligns under the open parenthesis. -indent_comma_paren = false # true/false +# How to indent a comma when inside parentheses. +# 0: Indent by one level (default) +# 1: Align under the open parenthesis +# -1: Preserve original indentation +indent_comma_paren = 0 # number -# Whether to indent a Boolean operator when inside a parenthesis. -# If true, aligns under the open parenthesis. -indent_bool_paren = false # true/false +# How to indent a Boolean operator when inside parentheses. +# 0: Indent by one level (default) +# 1: Align under the open parenthesis +# -1: Preserve original indentation +indent_bool_paren = 0 # number + +# Whether to ignore the indentation of a Boolean operator when outside +# parentheses. +indent_ignore_bool = false # true/false + +# Whether to ignore the indentation of an arithmetic operator. +indent_ignore_arith = false # true/false # Whether to indent a semicolon when inside a for parenthesis. # If true, aligns under the open for parenthesis. indent_semicolon_for_paren = false # true/false +# Whether to ignore the indentation of a semicolon outside of a 'for' +# statement. +indent_ignore_semicolon = false # true/false + # Whether to align the first expression to following ones -# if indent_bool_paren=true. +# if indent_bool_paren=1. indent_first_bool_expr = false # true/false # Whether to align the first expression to following ones @@ -1382,6 +1439,9 @@ indent_square_nl = false # true/false # (ESQL/C) Whether to preserve the relative indent of 'EXEC SQL' bodies. indent_preserve_sql = false # true/false +# Whether to ignore the indentation of an assignment operator. +indent_ignore_assign = false # true/false + # Whether to align continued statements at the '='. If false or if the '=' is # followed by a newline, the next line is indent one tab. # @@ -1982,7 +2042,8 @@ nl_after_semicolon = false # true/false nl_paren_dbrace_open = ignore # ignore/add/remove/force/not_defined # Whether to add a newline after the type in an unnamed temporary -# direct-list-initialization. +# direct-list-initialization, better: +# before a direct-list-initialization. nl_type_brace_init_lst = ignore # ignore/add/remove/force/not_defined # Whether to add a newline after the open brace in an unnamed temporary @@ -2240,15 +2301,15 @@ nl_typedef_blk_end = 0 # unsigned number # 0: No change (default). nl_typedef_blk_in = 0 # unsigned number -# The number of newlines before a block of variable definitions not at the top -# of a function body. If nl_after_access_spec is non-zero, that option takes -# precedence. +# The number of empty newlines before a block of variable definitions +# not at the top of a function body. If nl_after_access_spec is non-zero, +# that option takes precedence. # # 0: No change (default). nl_var_def_blk_start = 0 # unsigned number -# The number of newlines after a block of variable definitions not at the top -# of a function body. +# The number of empty newlines after a block of variable definitions +# not at the top of a function body. # # 0: No change (default). nl_var_def_blk_end = 0 # unsigned number @@ -2564,6 +2625,11 @@ align_var_def_inline = false # true/false # 0: Don't align (default). align_assign_span = 0 # unsigned number +# The span for aligning on '{' in braced init list. +# +# 0: Don't align (default). +align_braced_init_list_span = 0 # unsigned number + # The span for aligning on '=' in function prototype modifier. # # 0: Don't align (default). @@ -2575,6 +2641,17 @@ align_assign_func_proto_span = 0 # unsigned number # 0: No limit (default). align_assign_thresh = 0 # number +# Whether to align on the left most assignment when multiple +# definitions are found on the same line. +# Depends on 'align_assign_span' and 'align_assign_thresh' settings. +align_assign_on_multi_var_defs = false # true/false + +# The threshold for aligning on '{' in braced init list. +# Use a negative number for absolute thresholds. +# +# 0: No limit (default). +align_braced_init_list_thresh = 0 # number + # How to apply align_assign_span to function declaration "assignments", i.e. # 'virtual void foo() = 0' or '~foo() = {default|delete}'. # @@ -2780,7 +2857,7 @@ align_oc_decl_colon = false # true/false # (OC) Whether to not align parameters in an Objectve-C message call if first # colon is not on next line of the message call (the same way Xcode does -# aligment) +# alignment) align_oc_msg_colon_xcode_like = false # true/false # @@ -2980,12 +3057,17 @@ mod_full_brace_function = ignore # ignore/add/remove/force/not_defined mod_full_brace_if = add # ignore/add/remove/force/not_defined # Whether to enforce that all blocks of an 'if'/'else if'/'else' chain either -# have, or do not have, braces. If true, braces will be added if any block -# needs braces, and will only be removed if they can be removed from all -# blocks. -# -# Overrides mod_full_brace_if. -mod_full_brace_if_chain = false # true/false +# have, or do not have, braces. Overrides mod_full_brace_if. +# +# 0: Don't override mod_full_brace_if +# 1: Add braces to all blocks if any block needs braces and remove braces if +# they can be removed from all blocks +# 2: Add braces to all blocks if any block already has braces, regardless of +# whether it needs them +# 3: Add braces to all blocks if any block needs braces and remove braces if +# they can be removed from all blocks, except if all blocks have braces +# despite none needing them +mod_full_brace_if_chain = 0 # unsigned number # Whether to add braces to all blocks of an 'if'/'else if'/'else' chain. # If true, mod_full_brace_if_chain will only remove braces from an 'if' that @@ -3027,6 +3109,14 @@ mod_pawn_semicolon = false # true/false # statement, as in 'if (a && b > c)' => 'if (a && (b > c))'. mod_full_paren_if_bool = false # true/false +# Whether to fully parenthesize Boolean expressions after '=' +# statement, as in 'x = a && b > c;' => 'x = (a && (b > c));'. +mod_full_paren_assign_bool = false # true/false + +# Whether to fully parenthesize Boolean expressions after '=' +# statement, as in 'return a && b > c;' => 'return (a && (b > c));'. +mod_full_paren_return_bool = false # true/false + # Whether to remove superfluous semicolons. mod_remove_extra_semicolon = true # true/false @@ -3094,6 +3184,10 @@ mod_sort_incl_import_grouping_enabled = true # true/false # the close brace, as in 'case X: { ... } break;' => 'case X: { ... break; }'. mod_move_case_break = false # true/false +# Whether to move a 'return' that appears after a fully braced 'case' before +# the close brace, as in 'case X: { ... } return;' => 'case X: { ... return; }'. +mod_move_case_return = false # true/false + # Add or remove braces around a fully braced case statement. Will only remove # braces if there are no variable declarations in the block. mod_case_brace = remove # ignore/add/remove/force/not_defined @@ -3144,6 +3238,10 @@ pp_indent = remove # ignore/add/remove/force/not_defined # indented from column 1. pp_indent_at_level = false # true/false +# Whether to indent #if/#else/#endif at the parenthesis level if the brace +# level is 0. If false, these are indented from column 1. +pp_indent_at_level0 = false # true/false + # Specifies the number of columns to indent preprocessors per level # at brace level 0 (file-level). If pp_indent_at_level=false, also specifies # the number of columns to indent preprocessors per level @@ -3209,12 +3307,37 @@ pp_indent_func_def = true # true/false # Default: true pp_indent_extern = true # true/false -# Whether to indent braces directly inside #if, #else, and #endif. -# Only applies to the indent of the preprocesser that the braces are directly -# inside of. +# How to indent braces directly inside #if, #else, and #endif. +# Requires pp_if_indent_code=true and only applies to the indent of the +# preprocesser that the braces are directly inside of. +# 0: No extra indent +# 1: Indent by one level +# -1: Preserve original indentation # -# Default: true -pp_indent_brace = true # true/false +# Default: 1 +pp_indent_brace = 1 # number + +# Whether to print warning messages for unbalanced #if and #else blocks. +# This will print a message in the following cases: +# - if an #ifdef block ends on a different indent level than +# where it started from. Example: +# +# #ifdef TEST +# int i; +# { +# int j; +# #endif +# +# - an #elif/#else block ends on a different indent level than +# the corresponding #ifdef block. Example: +# +# #ifdef TEST +# int i; +# #else +# } +# int j; +# #endif +pp_warn_unbalanced_if = false # true/false # # Sort includes options @@ -3253,17 +3376,16 @@ use_indent_func_call_param = true # true/false # # true: indent_continue will be used only once # false: indent_continue will be used every time (default) +# +# Requires indent_ignore_first_continue=false. use_indent_continue_only_once = false # true/false -# The value might be used twice: -# - at the assignment -# - at the opening brace -# -# To prevent the double use of the indentation value, use this option with the -# value 'true'. +# The indentation can be: +# - after the assignment, at the '[' character +# - at the begin of the lambda body # -# true: indentation will be used only once -# false: indentation will be used every time (default) +# true: indentation will be after the assignment +# false: indentation will be at the begin of the lambda body (default) indent_cpp_lambda_only_once = false # true/false # Whether sp_after_angle takes precedence over sp_inside_fparen. This was the diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 610036f484..11c1fc6c2c 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3426,10 +3426,15 @@ describe('API', function() }, meths.parse_cmd('MyCommand test it', {})) end) it('errors for invalid command', function() - eq('Error while parsing command line', pcall_err(meths.parse_cmd, 'Fubar', {})) + eq('Error while parsing command line', pcall_err(meths.parse_cmd, '', {})) + eq('Error while parsing command line', pcall_err(meths.parse_cmd, '" foo', {})) + eq('Error while parsing command line: E492: Not an editor command: Fubar', + pcall_err(meths.parse_cmd, 'Fubar', {})) command('command! Fubar echo foo') - eq('Error while parsing command line', pcall_err(meths.parse_cmd, 'Fubar!', {})) - eq('Error while parsing command line', pcall_err(meths.parse_cmd, '4,6Fubar', {})) + eq('Error while parsing command line: E477: No ! allowed', + pcall_err(meths.parse_cmd, 'Fubar!', {})) + eq('Error while parsing command line: E481: No range allowed', + pcall_err(meths.parse_cmd, '4,6Fubar', {})) end) end) end) |