aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/eval.txt16
-rw-r--r--runtime/doc/lua.txt21
-rw-r--r--runtime/doc/starting.txt3
-rw-r--r--runtime/filetype.vim3
-rw-r--r--runtime/lua/vim/shared.lua46
-rw-r--r--runtime/plugin/diagnostic.vim26
-rw-r--r--src/nvim/api/private/helpers.c2
-rw-r--r--src/nvim/charset.c2
-rw-r--r--src/nvim/diff.c2
-rw-r--r--src/nvim/edit.c4
-rw-r--r--src/nvim/eval.c30
-rw-r--r--src/nvim/eval/encode.c5
-rw-r--r--src/nvim/eval/funcs.c6
-rw-r--r--src/nvim/eval/typval.c2
-rw-r--r--src/nvim/ex_getln.c4
-rw-r--r--src/nvim/getchar.c4
-rw-r--r--src/nvim/main.c3
-rw-r--r--src/nvim/message.c2
-rw-r--r--src/nvim/os/fs.c2
-rw-r--r--src/nvim/quickfix.c2
-rw-r--r--src/nvim/runtime.c4
-rw-r--r--src/nvim/shada.c40
-rw-r--r--src/nvim/spell.c2
-rw-r--r--src/nvim/state.c5
-rw-r--r--src/nvim/syntax.c20
-rw-r--r--src/nvim/testdir/test_filetype.vim2
-rw-r--r--src/nvim/testdir/test_functions.vim38
-rw-r--r--src/nvim/testdir/test_popup.vim4
-rw-r--r--src/nvim/undo.c4
-rw-r--r--test/functional/lua/vim_spec.lua38
30 files changed, 211 insertions, 131 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index d6f72b68f7..d9ecdb40de 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -3419,6 +3419,8 @@ complete_info([{what}]) *complete_info()*
"" Not in completion mode
"keyword" Keyword completion |i_CTRL-X_CTRL-N|
"ctrl_x" Just pressed CTRL-X |i_CTRL-X|
+ "scroll" Scrolling with |i_CTRL-X_CTRL-E| or
+ |i_CTRL-X_CTRL-Y|
"whole_line" Whole lines |i_CTRL-X_CTRL-L|
"files" File names |i_CTRL-X_CTRL-F|
"tags" Tags |i_CTRL-X_CTRL-]|
@@ -6863,29 +6865,31 @@ mode([expr]) Return a string that indicates the current mode.
niR Normal using |i_CTRL-O| in |Replace-mode|
niV Normal using |i_CTRL-O| in |Virtual-Replace-mode|
v Visual by character
+ vs Visual by character using |v_CTRL-O| in Select mode
V Visual by line
+ Vs Visual by line using |v_CTRL-O| in Select mode
CTRL-V Visual blockwise
+ CTRL-Vs Visual blockwise using |v_CTRL-O| in Select mode
s Select by character
S Select by line
CTRL-S Select blockwise
- vs Visual by character using |v_CTRL-O| from
- Select mode
- Vs Visual by line using |v_CTRL-O| from Select mode
- CTRL-Vs Visual blockwise using |v_CTRL-O| from Select mode
i Insert
ic Insert mode completion |compl-generic|
ix Insert mode |i_CTRL-X| completion
R Replace |R|
Rc Replace mode completion |compl-generic|
- Rv Virtual Replace |gR|
Rx Replace mode |i_CTRL-X| completion
+ Rv Virtual Replace |gR|
+ Rvc Virtual Replace mode completion |compl-generic|
+ Rvx Virtual Replace mode |i_CTRL-X| completion
c Command-line editing
cv Vim Ex mode |Q| or |gQ|
r Hit-enter prompt
rm The -- more -- prompt
- r? |:confirm| query of some sort
+ r? A |:confirm| query of some sort
! Shell or external command is executing
t Terminal mode: keys go to the job
+
This is useful in the 'statusline' option or when used
with |remote_expr()| In most other places it always returns
"c" or "n".
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 22e323baa7..f6daa70b4c 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -1373,20 +1373,25 @@ pesc({s}) *vim.pesc()*
See also: ~
https://github.com/rxi/lume
-split({s}, {sep}, {plain}) *vim.split()*
+split({s}, {sep}, {kwargs}) *vim.split()*
Splits a string at each instance of a separator.
Examples: >
- split(":aa::b:", ":") --> {'','aa','','b',''}
- split("axaby", "ab?") --> {'','x','y'}
- split(x*yz*o, "*", true) --> {'x','yz','o'}
+
+ split(":aa::b:", ":") --> {'','aa','','b',''}
+ split("axaby", "ab?") --> {'','x','y'}
+ split("x*yz*o", "*", {plain=true}) --> {'x','yz','o'}
+ split("|x|y|z|", "|", {trimempty=true}) --> {'x', 'y', 'z'}
<
Parameters: ~
- {s} String to split
- {sep} Separator string or pattern
- {plain} If `true` use `sep` literally (passed to
- String.find)
+ {s} String to split
+ {sep} Separator string or pattern
+ {kwargs} Keyword arguments:
+ • plain: (boolean) If `true` use `sep` literally
+ (passed to string.find)
+ • trimempty: (boolean) If `true` remove empty
+ items from the front and back of the list
Return: ~
List-like table of the split components.
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index 87a48e6d2a..bb775ec884 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -90,10 +90,11 @@ argument.
See |info-message| about capturing the text.
*--clean*
---clean Equivalent to "-u NONE -i NONE":
+--clean Mimics a fresh install of Nvim:
- Skips initializations from files and environment variables.
- No 'shada' file is read or written.
- Excludes user directories from 'runtimepath'
+ - Loads builtin plugins, unlike "-u NONE -i NONE".
*--noplugin*
--noplugin Skip loading plugins. Resets the 'loadplugins' option.
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 5e0c6fb32e..322215e1de 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -872,6 +872,9 @@ au BufNewFile,BufRead *.json-patch setf json
" Jupyter Notebook is also json
au BufNewFile,BufRead *.ipynb setf json
+" Other files that look like json
+au BufNewFile,BufRead .babelrc,.eslintrc,.prettierrc,.firebaserc setf json
+
" JSONC
au BufNewFile,BufRead *.jsonc setf jsonc
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 18c1e21049..b57b7ad4ad 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -98,17 +98,53 @@ end
--- <pre>
--- split(":aa::b:", ":") --> {'','aa','','b',''}
--- split("axaby", "ab?") --> {'','x','y'}
---- split(x*yz*o, "*", true) --> {'x','yz','o'}
+--- split("x*yz*o", "*", {plain=true}) --> {'x','yz','o'}
+--- split("|x|y|z|", "|", {trimempty=true}) --> {'x', 'y', 'z'}
--- </pre>
---
+---
---@see |vim.gsplit()|
---
---@param s String to split
---@param sep Separator string or pattern
----@param plain If `true` use `sep` literally (passed to String.find)
+---@param kwargs Keyword arguments:
+--- - plain: (boolean) If `true` use `sep` literally (passed to string.find)
+--- - trimempty: (boolean) If `true` remove empty items from the front
+--- and back of the list
---@returns List-like table of the split components.
-function vim.split(s,sep,plain)
- local t={} for c in vim.gsplit(s, sep, plain) do table.insert(t,c) end
+function vim.split(s, sep, kwargs)
+ local plain
+ local trimempty = false
+ if type(kwargs) == 'boolean' then
+ -- Support old signature for backward compatibility
+ plain = kwargs
+ else
+ vim.validate { kwargs = {kwargs, 't', true} }
+ kwargs = kwargs or {}
+ plain = kwargs.plain
+ trimempty = kwargs.trimempty
+ end
+
+ local t = {}
+ local skip = trimempty
+ for c in vim.gsplit(s, sep, plain) do
+ if c ~= "" then
+ skip = false
+ end
+
+ if not skip then
+ table.insert(t, c)
+ end
+ end
+
+ if trimempty then
+ for i = #t, 1, -1 do
+ if t[i] ~= "" then
+ break
+ end
+ table.remove(t, i)
+ end
+ end
+
return t
end
diff --git a/runtime/plugin/diagnostic.vim b/runtime/plugin/diagnostic.vim
deleted file mode 100644
index 2183623ac8..0000000000
--- a/runtime/plugin/diagnostic.vim
+++ /dev/null
@@ -1,26 +0,0 @@
-" :help vim.diagnostic
-
-hi default DiagnosticError ctermfg=1 guifg=Red
-hi default DiagnosticWarn ctermfg=3 guifg=Orange
-hi default DiagnosticInfo ctermfg=4 guifg=LightBlue
-hi default DiagnosticHint ctermfg=7 guifg=LightGrey
-
-hi default DiagnosticUnderlineError cterm=underline gui=underline guisp=Red
-hi default DiagnosticUnderlineWarn cterm=underline gui=underline guisp=Orange
-hi default DiagnosticUnderlineInfo cterm=underline gui=underline guisp=LightBlue
-hi default DiagnosticUnderlineHint cterm=underline gui=underline guisp=LightGrey
-
-hi default link DiagnosticVirtualTextError DiagnosticError
-hi default link DiagnosticVirtualTextWarn DiagnosticWarn
-hi default link DiagnosticVirtualTextInfo DiagnosticInfo
-hi default link DiagnosticVirtualTextHint DiagnosticHint
-
-hi default link DiagnosticFloatingError DiagnosticError
-hi default link DiagnosticFloatingWarn DiagnosticWarn
-hi default link DiagnosticFloatingInfo DiagnosticInfo
-hi default link DiagnosticFloatingHint DiagnosticHint
-
-hi default link DiagnosticSignError DiagnosticError
-hi default link DiagnosticSignWarn DiagnosticWarn
-hi default link DiagnosticSignInfo DiagnosticInfo
-hi default link DiagnosticSignHint DiagnosticHint
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 8089ca37bd..7b70c183c3 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -396,7 +396,7 @@ void set_option_to(uint64_t channel_id, void *to, int type, String name, Object
return;
}
- stringval = (char *)value.data.string.data;
+ stringval = value.data.string.data;
}
const sctx_T save_current_sctx = current_sctx;
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index f899ebf57c..d2f95ad81c 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -412,7 +412,7 @@ char *transstr(const char *const s, bool untab)
{
// Compute the length of the result, taking account of unprintable
// multi-byte characters.
- const size_t len = transstr_len((const char *)s, untab) + 1;
+ const size_t len = transstr_len(s, untab) + 1;
char *const buf = xmalloc(len);
transstr_buf(s, buf, len, untab);
return buf;
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 5c43b2498e..3a7bd21c70 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -1110,7 +1110,7 @@ static int diff_file(diffio_T *dio)
// Build the diff command and execute it. Always use -a, binary
// differences are of no use. Ignore errors, diff returns
// non-zero when differences have been found.
- vim_snprintf((char *)cmd, len, "diff %s%s%s%s%s%s%s%s %s",
+ vim_snprintf(cmd, len, "diff %s%s%s%s%s%s%s%s %s",
diff_a_works == kFalse ? "" : "-a ",
"",
(diff_flags & DIFF_IWHITE) ? "-b " : "",
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 45edbec4a6..5ac733285d 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -116,7 +116,7 @@ static char *ctrl_x_msgs[] =
static char *ctrl_x_mode_names[] = {
"keyword",
"ctrl_x",
- "unknown", // CTRL_X_SCROLL
+ "scroll",
"whole_line",
"files",
"tags",
@@ -3329,7 +3329,7 @@ void get_complete_info(list_T *what_list, dict_T *retdict)
// Return Insert completion mode name string
static char_u *ins_compl_mode(void)
{
- if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET || compl_started) {
+ if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET || ctrl_x_mode == CTRL_X_SCROLL || compl_started) {
return (char_u *)ctrl_x_mode_names[ctrl_x_mode & ~CTRL_X_WANT_IDENT];
}
return (char_u *)"";
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 768b82b464..a281c09042 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -514,8 +514,8 @@ int var_redir_start(char_u *name, int append)
ga_init(&redir_ga, (int)sizeof(char), 500);
// Parse the variable name (can be a dict or list entry).
- redir_endp = (char_u *)get_lval(redir_varname, NULL, redir_lval, false, false,
- 0, FNE_CHECK_START);
+ redir_endp = get_lval(redir_varname, NULL, redir_lval, false, false,
+ 0, FNE_CHECK_START);
if (redir_endp == NULL || redir_lval->ll_name == NULL
|| *redir_endp != NUL) {
clear_lval(redir_lval);
@@ -597,8 +597,8 @@ void var_redir_stop(void)
tv.vval.v_string = redir_ga.ga_data;
// Call get_lval() again, if it's inside a Dict or List it may
// have changed.
- redir_endp = (char_u *)get_lval(redir_varname, NULL, redir_lval,
- false, false, 0, FNE_CHECK_START);
+ redir_endp = get_lval(redir_varname, NULL, redir_lval,
+ false, false, 0, FNE_CHECK_START);
if (redir_endp != NULL && redir_lval->ll_name != NULL) {
set_var_lval(redir_lval, redir_endp, &tv, false, false, ".");
}
@@ -1711,7 +1711,7 @@ static const char *list_arg_vars(exarg_T *eap, const char *arg, int *first)
if (tofree != NULL) {
name = tofree;
}
- if (get_var_tv((const char *)name, len, &tv, NULL, true, false)
+ if (get_var_tv(name, len, &tv, NULL, true, false)
== FAIL) {
error = true;
} else {
@@ -2023,7 +2023,7 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co
}
lp->ll_exp_name = (char *)make_expanded_name(name, expr_start, expr_end,
- (char_u *)p);
+ p);
lp->ll_name = lp->ll_exp_name;
if (lp->ll_exp_name == NULL) {
/* Report an invalid expression in braces, unless the
@@ -2419,7 +2419,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, co
// handle +=, -=, *=, /=, %= and .=
di = NULL;
- if (get_var_tv((const char *)lp->ll_name, (int)STRLEN(lp->ll_name),
+ if (get_var_tv(lp->ll_name, (int)STRLEN(lp->ll_name),
&tv, &di, true, false) == OK) {
if ((di == NULL
|| (!var_check_ro(di->di_flags, lp->ll_name, TV_CSTRING)
@@ -3004,12 +3004,12 @@ int do_unlet(const char *const name, const size_t name_len, const bool forceit)
hashitem_T *hi = hash_find(ht, (const char_u *)varname);
if (HASHITEM_EMPTY(hi)) {
- hi = find_hi_in_scoped_ht((const char *)name, &ht);
+ hi = find_hi_in_scoped_ht(name, &ht);
}
if (hi != NULL && !HASHITEM_EMPTY(hi)) {
dictitem_T *const di = TV_DICT_HI2DI(hi);
- if (var_check_fixed(di->di_flags, (const char *)name, TV_CSTRING)
- || var_check_ro(di->di_flags, (const char *)name, TV_CSTRING)
+ if (var_check_fixed(di->di_flags, name, TV_CSTRING)
+ || var_check_ro(di->di_flags, name, TV_CSTRING)
|| var_check_lock(d->dv_lock, name, TV_CSTRING)) {
return FAIL;
}
@@ -3069,7 +3069,7 @@ static int do_lock_var(lval_T *lp, char_u *name_end FUNC_ATTR_UNUSED, exarg_T *e
ret = FAIL;
} else {
// Normal name or expanded name.
- dictitem_T *const di = find_var((const char *)lp->ll_name, lp->ll_name_len, NULL,
+ dictitem_T *const di = find_var(lp->ll_name, lp->ll_name_len, NULL,
true);
if (di == NULL) {
ret = FAIL;
@@ -4348,7 +4348,7 @@ static int call_func_rettv(char_u **const arg, typval_T *const rettv, const bool
funcexe.selfdict = selfdict;
funcexe.basetv = basetv;
const int ret = get_func_tv(funcname, is_lua ? *arg - funcname : -1, rettv,
- (char_u **)arg, &funcexe);
+ arg, &funcexe);
// Clear the funcref afterwards, so that deleting it while
// evaluating the arguments is possible (see test55).
@@ -9444,7 +9444,7 @@ static void set_var_const(const char *name, const size_t name_len, typval_T *con
// Search in parent scope which is possible to reference from lambda
if (v == NULL) {
- v = find_var_in_scoped_ht((const char *)name, name_len, true);
+ v = find_var_in_scoped_ht(name, name_len, true);
}
if (tv_is_func(*tv) && !var_check_func_name(name, v == NULL)) {
@@ -9654,7 +9654,7 @@ bool var_check_func_name(const char *const name, const bool new_var)
// Don't allow hiding a function. When "v" is not NULL we might be
// assigning another function to the same var, the type is checked
// below.
- if (new_var && function_exists((const char *)name, false)) {
+ if (new_var && function_exists(name, false)) {
EMSG2(_("E705: Variable name conflicts with existing function: %s"),
name);
return false;
@@ -11325,7 +11325,7 @@ bool var_exists(const char *var)
// get_name_len() takes care of expanding curly braces
const char *name = var;
- const int len = get_name_len((const char **)&var, &tofree, true, false);
+ const int len = get_name_len(&var, &tofree, true, false);
if (len > 0) {
typval_T tv;
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c
index 1c0afc89f5..5ef0045659 100644
--- a/src/nvim/eval/encode.c
+++ b/src/nvim/eval/encode.c
@@ -268,9 +268,8 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
|| TV_LIST_ITEM_TV(state->li)->vval.v_string != NULL);
for (size_t i = state->offset; i < state->li_length && p < buf_end; i++) {
assert(TV_LIST_ITEM_TV(state->li)->vval.v_string != NULL);
- const char ch = (char)(
- TV_LIST_ITEM_TV(state->li)->vval.v_string[state->offset++]);
- *p++ = (char)((char)ch == (char)NL ? (char)NUL : (char)ch);
+ const char ch = (char)(TV_LIST_ITEM_TV(state->li)->vval.v_string[state->offset++]);
+ *p++ = (char)(ch == (char)NL ? (char)NUL : ch);
}
if (p < buf_end) {
state->li = TV_LIST_ITEM_NEXT(state->list, state->li);
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 5569d74413..50e0b0b258 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -5149,7 +5149,7 @@ static void f_islocked(typval_T *argvars, typval_T *rettv, FunPtr fptr)
EMSG(_(e_trailing));
} else {
if (lv.ll_tv == NULL) {
- di = find_var((const char *)lv.ll_name, lv.ll_name_len, NULL, true);
+ di = find_var(lv.ll_name, lv.ll_name_len, NULL, true);
if (di != NULL) {
// Consider a variable locked when:
// 1. the variable itself is locked
@@ -5984,7 +5984,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
static void f_luaeval(typval_T *argvars, typval_T *rettv, FunPtr fptr)
FUNC_ATTR_NONNULL_ALL
{
- const char *const str = (const char *)tv_get_string_chk(&argvars[0]);
+ const char *const str = tv_get_string_chk(&argvars[0]);
if (str == NULL) {
return;
}
@@ -11358,7 +11358,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (new_cwd && *new_cwd != NUL) {
cwd = new_cwd;
// The new cwd must be a directory.
- if (!os_isdir_executable((const char *)cwd)) {
+ if (!os_isdir_executable(cwd)) {
EMSG2(_(e_invarg2), "expected valid directory");
shell_free_argv(argv);
return;
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 075b50a366..4c8789964f 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -3260,7 +3260,7 @@ const char *tv_get_string(const typval_T *const tv)
const char *tv_get_string_buf(const typval_T *const tv, char *const buf)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT
{
- const char *const res = (const char *)tv_get_string_buf_chk(tv, buf);
+ const char *const res = tv_get_string_buf_chk(tv, buf);
return res != NULL ? res : "";
}
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index a9990df58f..e0ff9bab3a 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -3037,7 +3037,7 @@ static void ui_ext_cmdline_show(CmdlineInfo *line)
line->cmdindent,
line->level);
if (line->special_char) {
- ui_call_cmdline_special_char(cchar_to_string((char)(line->special_char)),
+ ui_call_cmdline_special_char(cchar_to_string(line->special_char),
line->special_shift,
line->level);
}
@@ -3135,7 +3135,7 @@ void putcmdline(char c, int shift)
}
msg_no_more = false;
} else if (ccline.redraw_state != kCmdRedrawAll) {
- ui_call_cmdline_special_char(cchar_to_string((char)(c)), shift,
+ ui_call_cmdline_special_char(cchar_to_string(c), shift,
ccline.level);
}
cursorcmd();
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 15acd73aa5..f5f8a307d1 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -523,7 +523,7 @@ void restoreRedobuff(save_redo_T *save_redo)
void AppendToRedobuff(const char *s)
{
if (!block_redo) {
- add_buff(&redobuff, (const char *)s, -1L);
+ add_buff(&redobuff, s, -1L);
}
}
@@ -2861,7 +2861,7 @@ int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T
}
char_u *lhs = (char_u *)&args->lhs;
- char_u *rhs = (char_u *)args->rhs;
+ char_u *rhs = args->rhs;
char_u *orig_rhs = args->orig_rhs;
// check arguments and translate function keys
diff --git a/src/nvim/main.c b/src/nvim/main.c
index f801351d2d..069c253bff 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -345,7 +345,8 @@ int main(int argc, char **argv)
// Reset 'loadplugins' for "-u NONE" before "--cmd" arguments.
// Allows for setting 'loadplugins' there.
if (params.use_vimrc != NULL && strequal(params.use_vimrc, "NONE")) {
- p_lpl = false;
+ // When using --clean we still want to load plugins
+ p_lpl = params.clean;
}
// Execute --cmd arguments.
diff --git a/src/nvim/message.c b/src/nvim/message.c
index ed673b52d3..edde51e770 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -3191,7 +3191,7 @@ static void redir_write(const char *const str, const ptrdiff_t maxlen)
size_t len = maxlen == -1 ? STRLEN(s) : (size_t)maxlen;
if (capture_ga) {
- ga_concat_len(capture_ga, (const char *)str, len);
+ ga_concat_len(capture_ga, str, len);
}
if (redir_reg) {
write_reg_contents(redir_reg, s, len, true);
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index bbf70a4830..9675cfbb0f 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -134,7 +134,7 @@ bool os_isdir(const char_u *name)
bool os_isdir_executable(const char *name)
FUNC_ATTR_NONNULL_ALL
{
- int32_t mode = os_getperm((const char *)name);
+ int32_t mode = os_getperm(name);
if (mode < 0) {
return false;
}
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index eb0ba874f4..046e6dbd12 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1823,7 +1823,7 @@ static int qf_add_entry(qf_list_T *qfl, char_u *dir, char_u *fname, char_u *modu
if (type != 1 && !vim_isprintc(type)) { // only printable chars allowed
type = 0;
}
- qfp->qf_type = (char_u)type;
+ qfp->qf_type = type;
qfp->qf_valid = valid;
lastp = &qfl->qf_last;
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index e1669a8c19..0e2d23e69b 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -335,7 +335,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c
static void push_path(RuntimeSearchPath *search_path, Map(String, handle_T) *rtp_used,
char *entry, bool after)
{
- handle_T h = map_get(String, handle_T)(rtp_used, cstr_as_string((char *)entry));
+ handle_T h = map_get(String, handle_T)(rtp_used, cstr_as_string(entry));
if (h == 0) {
char *allocated = xstrdup(entry);
map_put(String, handle_T)(rtp_used, cstr_as_string(allocated), 1);
@@ -776,7 +776,7 @@ static bool pack_has_entries(char_u *buf)
{
int num_files;
char_u **files;
- char_u *(pat[]) = { (char_u *)buf };
+ char_u *(pat[]) = { buf };
if (gen_expand_wildcards(1, pat, &num_files, &files, EW_DIR) == OK) {
FreeWild(num_files, files);
}
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index bf245bec51..2d65db8437 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -65,25 +65,10 @@ KHASH_SET_INIT_INT64(bufset)
KHASH_MAP_INIT_STR(fnamebufs, buf_T *)
KHASH_SET_INIT_STR(strset)
-#define copy_option_part(src, dest, ...) \
- ((char *)copy_option_part((char_u **)src, (char_u *)dest, __VA_ARGS__))
#define find_shada_parameter(...) \
((const char *)find_shada_parameter(__VA_ARGS__))
-#define home_replace_save(a, b) \
- ((char *)home_replace_save(a, (char_u *)b))
-#define home_replace(a, b, c, d, e) \
- home_replace(a, (char_u *)b, (char_u *)c, d, e)
-#define vim_rename(a, b) \
- (vim_rename((char_u *)a, (char_u *)b))
-#define mb_strnicmp(a, b, c) \
- (mb_strnicmp((char_u *)a, (char_u *)b, c))
#define path_try_shorten_fname(b) \
((char *)path_try_shorten_fname((char_u *)b))
-#define buflist_new(ffname, sfname, ...) \
- (buflist_new((char_u *)ffname, (char_u *)sfname, __VA_ARGS__))
-#define os_isdir(f) (os_isdir((char_u *)f))
-#define regtilde(s, m) ((char *)regtilde((char_u *)s, m))
-#define path_tail_with_sep(f) ((char *)path_tail_with_sep((char_u *)f))
#define SEARCH_KEY_MAGIC "sm"
#define SEARCH_KEY_SMARTCASE "sc"
@@ -1271,7 +1256,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
// string is close to useless: you can only use it with :& or :~ and
// that’s all because s//~ is not available until the first call to
// regtilde. Vim was not calling this for some reason.
- (void)regtilde(cur_entry.data.sub_string.sub, p_magic);
+ (void)(char *)regtilde((char_u *)cur_entry.data.sub_string.sub, p_magic);
// Do not free shada entry: its allocated memory was saved above.
break;
case kSDItemHistoryEntry:
@@ -1362,8 +1347,9 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
case kSDItemBufferList:
for (size_t i = 0; i < cur_entry.data.buffer_list.size; i++) {
char *const sfname = path_try_shorten_fname(cur_entry.data.buffer_list.buffers[i].fname);
- buf_T *const buf = buflist_new(cur_entry.data.buffer_list.buffers[i].fname, sfname, 0,
- BLN_LISTED);
+ buf_T *const buf =
+ buflist_new((char_u *)cur_entry.data.buffer_list.buffers[i].fname, (char_u *)sfname, 0,
+ BLN_LISTED);
if (buf != NULL) {
RESET_FMARK(&buf->b_last_cursor,
cur_entry.data.buffer_list.buffers[i].pos, 0);
@@ -2694,7 +2680,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, ShaDaReadDef
.timestamp = sub.timestamp,
.data = {
.sub_string = {
- .sub = (char *)sub.sub,
+ .sub = sub.sub,
.additional_elements = sub.additional_elements,
}
}
@@ -3037,11 +3023,11 @@ shada_write_file_open: {}
}
if (nomerge) {
shada_write_file_nomerge: {}
- char *const tail = path_tail_with_sep(fname);
+ char *const tail = (char *)path_tail_with_sep((char_u *)fname);
if (tail != fname) {
const char tail_save = *tail;
*tail = NUL;
- if (!os_isdir(fname)) {
+ if (!os_isdir((char_u *)fname)) {
int ret;
char *failed_dir;
if ((ret = os_mkdir_recurse(fname, 0700, &failed_dir)) != 0) {
@@ -3092,7 +3078,7 @@ shada_write_file_nomerge: {}
// overwrite a user’s viminfo file after a "su root", with a
// viminfo file that the user can't read.
FileInfo old_info;
- if (os_fileinfo((char *)fname, &old_info)) {
+ if (os_fileinfo(fname, &old_info)) {
if (getuid() == ROOT_UID) {
if (old_info.stat.st_uid != ROOT_UID
|| old_info.stat.st_gid != getgid()) {
@@ -3116,7 +3102,7 @@ shada_write_file_nomerge: {}
}
}
#endif
- if (vim_rename(tempname, fname) == -1) {
+ if (vim_rename((char_u *)tempname, (char_u *)fname) == -1) {
EMSG3(_(RNERR "Can't rename ShaDa file from %s to %s!"),
tempname, fname);
} else {
@@ -4015,13 +4001,13 @@ static bool shada_removable(const char *name)
char part[MAXPATHL + 1];
bool retval = false;
- char *new_name = home_replace_save(NULL, name);
+ char *new_name = (char *)home_replace_save(NULL, (char_u *)name);
for (p = (char *)p_shada; *p; ) {
- (void)copy_option_part(&p, part, ARRAY_SIZE(part), ", ");
+ (void)(char *)copy_option_part((char_u **)&p, (char_u *)part, ARRAY_SIZE(part), ", ");
if (part[0] == 'r') {
- home_replace(NULL, part + 1, NameBuff, MAXPATHL, true);
+ home_replace(NULL, (char_u *)(part + 1), (char_u *)NameBuff, MAXPATHL, true);
size_t n = STRLEN(NameBuff);
- if (mb_strnicmp(NameBuff, new_name, n) == 0) {
+ if (mb_strnicmp((char_u *)NameBuff, (char_u *)new_name, n) == 0) {
retval = true;
break;
}
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 3e56ad561b..450ec891ad 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -6073,7 +6073,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res)
wordlen = 0;
for (const char_u *s = inword; *s != NUL; ) {
const char_u *t = s;
- c = mb_cptr2char_adv((const char_u **)&s);
+ c = mb_cptr2char_adv(&s);
if (slang->sl_rem_accents) {
if (utf_class(c) == 0) {
if (did_white) {
diff --git a/src/nvim/state.c b/src/nvim/state.c
index a9f3d67849..04271d750c 100644
--- a/src/nvim/state.c
+++ b/src/nvim/state.c
@@ -161,6 +161,11 @@ char *get_mode(void)
if (State & VREPLACE_FLAG) {
buf[0] = 'R';
buf[1] = 'v';
+ if (ins_compl_active()) {
+ buf[2] = 'c';
+ } else if (ctrl_x_mode_not_defined_yet()) {
+ buf[2] = 'x';
+ }
} else {
if (State & REPLACE_FLAG) {
buf[0] = 'R';
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index d2c94d9fe8..49f54dcfe1 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -6217,6 +6217,26 @@ static const char *highlight_init_both[] = {
"default link Delimiter Special",
"default link SpecialComment Special",
"default link Debug Special",
+ "default DiagnosticError ctermfg=1 guifg=Red",
+ "default DiagnosticWarn ctermfg=3 guifg=Orange",
+ "default DiagnosticInfo ctermfg=4 guifg=LightBlue",
+ "default DiagnosticHint ctermfg=7 guifg=LightGrey",
+ "default DiagnosticUnderlineError cterm=underline gui=underline guisp=Red",
+ "default DiagnosticUnderlineWarn cterm=underline gui=underline guisp=Orange",
+ "default DiagnosticUnderlineInfo cterm=underline gui=underline guisp=LightBlue",
+ "default DiagnosticUnderlineHint cterm=underline gui=underline guisp=LightGrey",
+ "default link DiagnosticVirtualTextError DiagnosticError",
+ "default link DiagnosticVirtualTextWarn DiagnosticWarn",
+ "default link DiagnosticVirtualTextInfo DiagnosticInfo",
+ "default link DiagnosticVirtualTextHint DiagnosticHint",
+ "default link DiagnosticFloatingError DiagnosticError",
+ "default link DiagnosticFloatingWarn DiagnosticWarn",
+ "default link DiagnosticFloatingInfo DiagnosticInfo",
+ "default link DiagnosticFloatingHint DiagnosticHint",
+ "default link DiagnosticSignError DiagnosticError",
+ "default link DiagnosticSignWarn DiagnosticWarn",
+ "default link DiagnosticSignInfo DiagnosticInfo",
+ "default link DiagnosticSignHint DiagnosticHint",
NULL
};
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index 9eb64f68ef..4a9cb4a8d8 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -259,7 +259,7 @@ let s:filename_checks = {
\ 'jgraph': ['file.jgr'],
\ 'jovial': ['file.jov', 'file.j73', 'file.jovial'],
\ 'jproperties': ['file.properties', 'file.properties_xx', 'file.properties_xx_xx', 'some.properties_xx_xx_file'],
- \ 'json': ['file.json', 'file.jsonp', 'file.json-patch', 'file.webmanifest', 'Pipfile.lock', 'file.ipynb'],
+ \ 'json': ['file.json', 'file.jsonp', 'file.json-patch', 'file.webmanifest', 'Pipfile.lock', 'file.ipynb', '.babelrc', '.eslintrc', '.prettierrc', '.firebaserc'],
\ 'jsonc': ['file.jsonc'],
\ 'jsp': ['file.jsp'],
\ 'julia': ['file.jl'],
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index e82fefc7fc..366615821c 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -585,6 +585,8 @@ func Test_mode()
exe "normal iabc\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
+ exe "normal R\<F2>\<Esc>"
+ call assert_equal('R-R', g:current_modes)
" R_CTRL-P: Multiple matches
exe "normal RBa\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
@@ -619,6 +621,42 @@ func Test_mode()
exe "normal Rabc\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
+ exe "normal gR\<F2>\<Esc>"
+ call assert_equal('R-Rv', g:current_modes)
+ " gR_CTRL-P: Multiple matches
+ exe "normal gRBa\<C-P>\<F2>\<Esc>u"
+ call assert_equal('R-Rvc', g:current_modes)
+ " gR_CTRL-P: Single match
+ exe "normal gRBro\<C-P>\<F2>\<Esc>u"
+ call assert_equal('R-Rvc', g:current_modes)
+ " gR_CTRL-X
+ exe "normal gRBa\<C-X>\<F2>\<Esc>u"
+ call assert_equal('R-Rvx', g:current_modes)
+ " gR_CTRL-X CTRL-P: Multiple matches
+ exe "normal gRBa\<C-X>\<C-P>\<F2>\<Esc>u"
+ call assert_equal('R-Rvc', g:current_modes)
+ " gR_CTRL-X CTRL-P: Single match
+ exe "normal gRBro\<C-X>\<C-P>\<F2>\<Esc>u"
+ call assert_equal('R-Rvc', g:current_modes)
+ " gR_CTRL-X CTRL-P + CTRL-P: Single match
+ exe "normal gRBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u"
+ call assert_equal('R-Rvc', g:current_modes)
+ " gR_CTRL-X CTRL-L: Multiple matches
+ exe "normal gR\<C-X>\<C-L>\<F2>\<Esc>u"
+ call assert_equal('R-Rvc', g:current_modes)
+ " gR_CTRL-X CTRL-L: Single match
+ exe "normal gRBlu\<C-X>\<C-L>\<F2>\<Esc>u"
+ call assert_equal('R-Rvc', g:current_modes)
+ " gR_CTRL-P: No match
+ exe "normal gRCom\<C-P>\<F2>\<Esc>u"
+ call assert_equal('R-Rvc', g:current_modes)
+ " gR_CTRL-X CTRL-P: No match
+ exe "normal gRCom\<C-X>\<C-P>\<F2>\<Esc>u"
+ call assert_equal('R-Rvc', g:current_modes)
+ " gR_CTRL-X CTRL-L: No match
+ exe "normal gRabc\<C-X>\<C-L>\<F2>\<Esc>u"
+ call assert_equal('R-Rvc', g:current_modes)
+
call assert_equal('n', mode(0))
call assert_equal('n', mode(1))
diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim
index 710450293c..eb367cfe5c 100644
--- a/src/nvim/testdir/test_popup.vim
+++ b/src/nvim/testdir/test_popup.vim
@@ -950,6 +950,10 @@ func Test_popup_complete_info_01()
\ ["\<C-X>", 'ctrl_x'],
\ ["\<C-X>\<C-N>", 'keyword'],
\ ["\<C-X>\<C-P>", 'keyword'],
+ \ ["\<C-X>\<C-E>", 'scroll'],
+ \ ["\<C-X>\<C-Y>", 'scroll'],
+ \ ["\<C-X>\<C-E>\<C-E>\<C-Y>", 'scroll'],
+ \ ["\<C-X>\<C-Y>\<C-E>\<C-Y>", 'scroll'],
\ ["\<C-X>\<C-L>", 'whole_line'],
\ ["\<C-X>\<C-F>", 'files'],
\ ["\<C-X>\<C-]>", 'tags'],
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index af214815f8..d5857ff8b9 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -1407,7 +1407,7 @@ void u_read_undo(char *name, const char_u *hash, const char_u *orig_name FUNC_AT
FileInfo file_info_orig;
FileInfo file_info_undo;
if (os_fileinfo((const char *)orig_name, &file_info_orig)
- && os_fileinfo((char *)file_name, &file_info_undo)
+ && os_fileinfo(file_name, &file_info_undo)
&& file_info_orig.stat.st_uid != file_info_undo.stat.st_uid
&& file_info_undo.stat.st_uid != getuid()) {
if (p_verbose > 0) {
@@ -1420,7 +1420,7 @@ void u_read_undo(char *name, const char_u *hash, const char_u *orig_name FUNC_AT
}
#endif
} else {
- file_name = (char *)name;
+ file_name = name;
}
if (p_verbose > 0) {
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index a066cfbc10..8651a38025 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -237,29 +237,34 @@ describe('lua stdlib', function()
end)
it("vim.split", function()
- local split = function(str, sep, plain)
- return exec_lua('return vim.split(...)', str, sep, plain)
+ local split = function(str, sep, kwargs)
+ return exec_lua('return vim.split(...)', str, sep, kwargs)
end
local tests = {
- { "a,b", ",", false, { 'a', 'b' } },
- { ":aa::bb:", ":", false, { '', 'aa', '', 'bb', '' } },
- { "::ee::ff:", ":", false, { '', '', 'ee', '', 'ff', '' } },
- { "ab", ".", false, { '', '', '' } },
- { "a1b2c", "[0-9]", false, { 'a', 'b', 'c' } },
- { "xy", "", false, { 'x', 'y' } },
- { "here be dragons", " ", false, { "here", "be", "dragons"} },
- { "axaby", "ab?", false, { '', 'x', 'y' } },
- { "f v2v v3v w2w ", "([vw])2%1", false, { 'f ', ' v3v ', ' ' } },
- { "", "", false, {} },
- { "", "a", false, { '' } },
- { "x*yz*oo*l", "*", true, { 'x', 'yz', 'oo', 'l' } },
+ { "a,b", ",", false, false, { 'a', 'b' } },
+ { ":aa::bb:", ":", false, false, { '', 'aa', '', 'bb', '' } },
+ { ":aa::bb:", ":", false, true, { 'aa', '', 'bb' } },
+ { "::ee::ff:", ":", false, false, { '', '', 'ee', '', 'ff', '' } },
+ { "::ee::ff:", ":", false, true, { 'ee', '', 'ff' } },
+ { "ab", ".", false, false, { '', '', '' } },
+ { "a1b2c", "[0-9]", false, false, { 'a', 'b', 'c' } },
+ { "xy", "", false, false, { 'x', 'y' } },
+ { "here be dragons", " ", false, false, { "here", "be", "dragons"} },
+ { "axaby", "ab?", false, false, { '', 'x', 'y' } },
+ { "f v2v v3v w2w ", "([vw])2%1", false, false, { 'f ', ' v3v ', ' ' } },
+ { "", "", false, false, {} },
+ { "", "a", false, false, { '' } },
+ { "x*yz*oo*l", "*", true, false, { 'x', 'yz', 'oo', 'l' } },
}
for _, t in ipairs(tests) do
- eq(t[4], split(t[1], t[2], t[3]))
+ eq(t[5], split(t[1], t[2], {plain=t[3], trimempty=t[4]}))
end
+ -- Test old signature
+ eq({'x', 'yz', 'oo', 'l'}, split("x*yz*oo*l", "*", true))
+
local loops = {
{ "abc", ".-" },
}
@@ -283,9 +288,8 @@ describe('lua stdlib', function()
vim/shared.lua:0: in function <vim/shared.lua:0>]]),
pcall_err(split, 'string', 1))
eq(dedent([[
- Error executing lua: vim/shared.lua:0: plain: expected boolean, got number
+ Error executing lua: vim/shared.lua:0: kwargs: expected table, got number
stack traceback:
- vim/shared.lua:0: in function 'gsplit'
vim/shared.lua:0: in function <vim/shared.lua:0>]]),
pcall_err(split, 'string', 'string', 1))
end)