diff options
-rw-r--r-- | .github/workflows/ci.yml | 4 | ||||
-rwxr-xr-x | .github/workflows/env.sh | 5 | ||||
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | runtime/doc/api.txt | 3 | ||||
-rw-r--r-- | runtime/doc/lsp.txt | 2 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 13 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 2 | ||||
-rw-r--r-- | src/nvim/api/vimscript.c | 4 | ||||
-rw-r--r-- | src/nvim/buffer_updates.c | 2 | ||||
-rw-r--r-- | src/nvim/edit.c | 4 | ||||
-rw-r--r-- | src/nvim/eval.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 10 | ||||
-rw-r--r-- | src/nvim/extmark.c | 10 | ||||
-rw-r--r-- | src/nvim/extmark.h | 2 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 38 |
15 files changed, 76 insertions, 27 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea3185d2a1..1aa0906ffc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,6 +119,10 @@ jobs: cc: clang-13 runner: ubuntu-20.04 os: linux + - flavor: uchar + cc: gcc + runner: ubuntu-20.04 + os: linux - cc: clang runner: macos-10.15 os: osx diff --git a/.github/workflows/env.sh b/.github/workflows/env.sh index bd170f92fb..ca1194efa9 100755 --- a/.github/workflows/env.sh +++ b/.github/workflows/env.sh @@ -45,6 +45,11 @@ TSAN_OPTIONS=log_path=$GITHUB_WORKSPACE/build/log/tsan CLANG_SANITIZER=TSAN EOF ;; + uchar) + cat <<EOF >> "$GITHUB_ENV" +BUILD_UCHAR=1 +EOF + ;; lint) # Re-enable once system deps are available # BUILD_FLAGS="$BUILD_FLAGS -DLIBLUV_LIBRARY:FILEPATH=/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/lua/5.1/luv.so -DLIBLUV_INCLUDE_DIR:PATH=/usr/include/lua5.1" diff --git a/CMakeLists.txt b/CMakeLists.txt index 82d9a42db2..01df172ed4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -370,7 +370,7 @@ option(CI_BUILD "CI, extra flags will be set" OFF) if(CI_BUILD) message(STATUS "CI build enabled") add_compile_options(-Werror) - if(DEFINED ENV{BUILD_32BIT}) + if(DEFINED ENV{BUILD_UCHAR}) # Get some test coverage for unsigned char add_compile_options(-funsigned-char) endif() diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 242546f87d..50fe60a0fc 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -1782,8 +1782,7 @@ nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()* item was specified and two elements if both range items were specified. • count: (number) Any |<count>| that was supplied to the - command. -1 if command cannot take a count. Mutually - exclusive with "range". + command. -1 if command cannot take a count. • reg: (number) The optional command |<register>|, if specified. Empty string if not specified or if command cannot take a register. diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index be46bbfa66..299efe5bf6 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -1703,7 +1703,7 @@ open_floating_preview({contents}, {syntax}, {opts}) • width: (number) width of floating window • wrap: (boolean, default true) wrap long lines - • wrap_at: (string) character to wrap at for + • wrap_at: (number) character to wrap at for computing height when wrap is enabled • max_width: (number) maximal width of floating window 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/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 72dfb3cd76..bb87e8372b 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1384,7 +1384,7 @@ end --- - height: (number) height of floating window --- - width: (number) width of floating window --- - wrap: (boolean, default true) wrap long lines ---- - wrap_at: (string) character to wrap at for computing height when wrap is enabled +--- - wrap_at: (number) character to wrap at for computing height when wrap is enabled --- - max_width: (number) maximal width of floating window --- - max_height: (number) maximal height of floating window --- - pad_top: (number) number of lines to pad contents at top diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index d3675a3c40..9396435466 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -752,7 +752,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, E /// no range was specified, one element if only a single range item was /// specified and two elements if both range items were specified. /// - count: (number) Any |<count>| that was supplied to the command. -1 if command cannot -/// take a count. Mutually exclusive with "range". +/// take a count. /// - reg: (number) The optional command |<register>|, if specified. Empty string if not /// specified or if command cannot take a register. /// - bang: (boolean) Whether command contains a |<bang>| (!) modifier. @@ -853,7 +853,7 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err) PUT(result, "cmd", CSTR_TO_OBJ((char *)get_command_name(NULL, ea.cmdidx))); } - if ((ea.argt & EX_RANGE) && !(ea.argt & EX_COUNT) && ea.addr_count > 0) { + if ((ea.argt & EX_RANGE) && ea.addr_count > 0) { Array range = ARRAY_DICT_INIT; if (ea.addr_count > 1) { ADD(range, INTEGER_OBJ(ea.line1)); diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c index 49e3a03dac..3e2d04b3a2 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, linenr_T start_row, colnr_T start_col, bcount_t start_byte, +void buf_updates_send_splice(buf_T *buf, int 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 ab80f09228..a608612af5 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2002,7 +2002,7 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang // TODO(bfredl): test for crazy edge cases, like we stand on a TAB or // something? does this even do the right text change then? int delta = orig_col - new_col; - extmark_splice_cols(curbuf, curwin->w_cursor.lnum - 1, new_col, + extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum - 1, new_col, delta < 0 ? -delta : 0, delta > 0 ? delta : 0, kExtmarkUndo); @@ -9118,7 +9118,7 @@ static bool ins_tab(void) } } if (!(State & VREPLACE_FLAG)) { - extmark_splice_cols(curbuf, fpos.lnum - 1, change_col, + extmark_splice_cols(curbuf, (int)fpos.lnum - 1, change_col, cursor->col - change_col, fpos.col - change_col, kExtmarkUndo); } 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/ex_docmd.c b/src/nvim/ex_docmd.c index d2b833305b..a54d1a14ce 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1320,7 +1320,7 @@ static void parse_register(exarg_T *eap) } } -static int parse_count(exarg_T *eap, char **errormsg) +static int parse_count(exarg_T *eap, char **errormsg, bool validate) { // Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a // count, it's a buffer name. @@ -1348,7 +1348,7 @@ static int parse_count(exarg_T *eap, char **errormsg) eap->line2 += n - 1; eap->addr_count++; // Be vi compatible: no error message for out of range. - if (eap->line2 > curbuf->b_ml.ml_line_count) { + if (validate && eap->line2 > curbuf->b_ml.ml_line_count) { eap->line2 = curbuf->b_ml.ml_line_count; } } @@ -1426,7 +1426,7 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er } p = find_command(eap, NULL); - // Set command attribute type and parse command range + // Set command address type and parse command range set_cmd_addr_type(eap, (char_u *)p); eap->cmd = cmd; if (parse_cmd_address(eap, errormsg, false) == FAIL) { @@ -1499,7 +1499,7 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er // Parse register and count parse_register(eap); - if (parse_count(eap, errormsg) == FAIL) { + if (parse_count(eap, errormsg, false) == FAIL) { return false; } @@ -1981,7 +1981,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter // Parse register and count parse_register(&ea); - if (parse_count(&ea, &errormsg) == FAIL) { + if (parse_count(&ea, &errormsg, true) == FAIL) { goto doend; } diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index 09ea2be4fe..f367bc66e0 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, linenr_T l_row, colnr_T l_col, linenr_T u_row, colnr_T u_col) +void u_extmark_copy(buf_T *buf, int l_row, colnr_T l_col, int u_row, colnr_T u_col) { u_header_T *uhp = u_force_get_undo_header(buf); if (!uhp) { @@ -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, linenr_T start_row, colnr_T start_col, int old_row, colnr_T old_col, +void extmark_splice(buf_T *buf, int 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, linenr_T start_row, colnr_T start_col, int old_r undo); } -void extmark_splice_impl(buf_T *buf, linenr_T start_row, colnr_T start_col, bcount_t start_byte, +void extmark_splice_impl(buf_T *buf, int 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,7 +588,7 @@ void extmark_splice_impl(buf_T *buf, linenr_T start_row, colnr_T start_col, bcou // beginning and right-gravity at the end need not be preserved. // Also be smart about marks that already have been saved (important for // merge!) - linenr_T end_row = start_row + old_row; + int 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); } @@ -656,7 +656,7 @@ void extmark_splice_impl(buf_T *buf, linenr_T start_row, colnr_T start_col, bcou } } -void extmark_splice_cols(buf_T *buf, linenr_T start_row, colnr_T start_col, colnr_T old_col, +void extmark_splice_cols(buf_T *buf, int 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 84d1e8d03b..b856a1148f 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 { - linenr_T start_row; + int start_row; colnr_T start_col; int old_row; colnr_T old_col; diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 11c1fc6c2c..d68f299277 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3176,7 +3176,7 @@ describe('API', function() cmd = 'buffer', args = {}, bang = false, - range = {}, + range = { 1 }, count = 1, reg = '', addr = 'buf', @@ -3243,6 +3243,42 @@ describe('API', function() } }, meths.parse_cmd('put +', {})) end) + it('works with range, count and register', function() + eq({ + cmd = 'delete', + args = {}, + bang = false, + range = { 3, 7 }, + count = 7, + reg = '*', + addr = 'line', + magic = { + file = false, + bar = true + }, + nargs = '0', + nextcmd = '', + mods = { + browse = false, + confirm = false, + emsg_silent = false, + hide = false, + keepalt = false, + keepjumps = false, + keepmarks = false, + keeppatterns = false, + lockmarks = false, + noautocmd = false, + noswapfile = false, + sandbox = false, + silent = false, + vertical = false, + split = "", + tab = 0, + verbose = -1 + } + }, meths.parse_cmd('1,3delete * 5', {})) + end) it('works with bang', function() eq({ cmd = 'write', |