aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer_defs.h7
-rw-r--r--src/nvim/eval.c21
-rw-r--r--src/nvim/eval.h1
-rw-r--r--src/nvim/eval.lua8
-rw-r--r--src/nvim/eval/funcs.c63
-rw-r--r--src/nvim/ex_cmds2.c9
-rw-r--r--src/nvim/indent.c10
-rw-r--r--src/nvim/lua/vim.lua80
-rw-r--r--src/nvim/main.c2
-rw-r--r--src/nvim/message.c7
-rw-r--r--src/nvim/move.c2
-rw-r--r--src/nvim/option.c6
-rw-r--r--src/nvim/screen.c12
-rw-r--r--src/nvim/testdir/test_breakindent.vim59
-rw-r--r--src/nvim/testdir/test_cursor_func.vim15
-rw-r--r--src/nvim/testdir/test_filetype.vim1
-rw-r--r--src/nvim/testdir/test_match.vim44
-rw-r--r--src/nvim/testdir/test_options.vim7
-rw-r--r--src/nvim/testdir/test_startup.vim9
19 files changed, 321 insertions, 42 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index b87a2ba721..d696eedbb7 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -1330,12 +1330,13 @@ struct window_S {
uint32_t w_p_fde_flags; // flags for 'foldexpr'
uint32_t w_p_fdt_flags; // flags for 'foldtext'
int *w_p_cc_cols; // array of columns to highlight or NULL
- int w_p_brimin; // minimum width for breakindent
- int w_p_brishift; // additional shift for breakindent
- bool w_p_brisbr; // sbr in 'briopt'
long w_p_siso; // 'sidescrolloff' local value
long w_p_so; // 'scrolloff' local value
+ int w_briopt_min; // minimum width for breakindent
+ int w_briopt_shift; // additional shift for breakindent
+ bool w_briopt_sbr; // sbr in 'briopt'
+
// transform a pointer to a "onebuf" option into a "allbuf" option
#define GLOBAL_WO(p) ((char *)p + sizeof(winopt_T))
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index ced3613005..017d46e802 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -63,6 +63,7 @@ static char *e_missbrac = N_("E111: Missing ']'");
static char *e_dictrange = N_("E719: Cannot use [:] with a Dictionary");
static char *e_illvar = N_("E461: Illegal variable name: %s");
static char *e_cannot_mod = N_("E995: Cannot modify existing variable");
+static char *e_invalwindow = N_("E957: Invalid window number");
// TODO(ZyX-I): move to eval/executor
static char *e_letwrong = N_("E734: Wrong variable type for %s=");
@@ -229,6 +230,7 @@ static struct vimvar {
VV(VV_ECHOSPACE, "echospace", VAR_NUMBER, VV_RO),
VV(VV_EXITING, "exiting", VAR_NUMBER, VV_RO),
VV(VV_LUA, "lua", VAR_PARTIAL, VV_RO),
+ VV(VV_ARGV, "argv", VAR_LIST, VV_RO),
};
#undef VV
@@ -6778,7 +6780,7 @@ int matchadd_dict_arg(typval_T *tv, const char **conceal_char,
if ((di = tv_dict_find(tv->vval.v_dict, S_LEN("window"))) != NULL) {
*win = find_win_by_nr_or_id(&di->di_tv);
if (*win == NULL) {
- EMSG(_("E957: Invalid window number"));
+ EMSG(_(e_invalwindow));
return FAIL;
}
}
@@ -8109,6 +8111,23 @@ void set_vim_var_dict(const VimVarIndex idx, dict_T *const val)
}
}
+/// Set the v:argv list.
+void set_argv_var(char **argv, int argc)
+{
+ list_T *l = tv_list_alloc(argc);
+ int i;
+
+ if (l == NULL) {
+ getout(1);
+ }
+ tv_list_set_lock(l, VAR_FIXED);
+ for (i = 0; i < argc; i++) {
+ tv_list_append_string(l, (const char *const)argv[i], -1);
+ TV_LIST_ITEM_TV(tv_list_last(l))->v_lock = VAR_FIXED;
+ }
+ set_vim_var_list(VV_ARGV, l);
+}
+
/*
* Set v:register if needed.
*/
diff --git a/src/nvim/eval.h b/src/nvim/eval.h
index ebc0eb0b1a..0b4cbb3b4d 100644
--- a/src/nvim/eval.h
+++ b/src/nvim/eval.h
@@ -159,6 +159,7 @@ typedef enum {
VV_ECHOSPACE,
VV_EXITING,
VV_LUA,
+ VV_ARGV,
} VimVarIndex;
/// All recognized msgpack types
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 65c4cfe553..51872a7ba8 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -64,7 +64,7 @@ return {
chansend={args=2},
char2nr={args={1, 2}},
cindent={args=1},
- clearmatches={},
+ clearmatches={args={0, 1}},
col={args=1},
complete={args=2},
complete_add={args=1},
@@ -149,7 +149,7 @@ return {
getjumplist={args={0, 2}},
getline={args={1, 2}},
getloclist={args={1, 2}},
- getmatches={},
+ getmatches={args={0, 1}},
getpid={},
getpos={args=1},
getqflist={args={0, 1}},
@@ -227,7 +227,7 @@ return {
matchadd={args={2, 5}},
matchaddpos={args={2, 5}},
matcharg={args=1},
- matchdelete={args=1},
+ matchdelete={args={1, 2}},
matchend={args={2, 4}},
matchlist={args={2, 4}},
matchstr={args={2, 4}},
@@ -293,7 +293,7 @@ return {
setfperm={args=2},
setline={args=2},
setloclist={args={2, 4}},
- setmatches={args=1},
+ setmatches={args={1, 2}},
setpos={args=2},
setqflist={args={1, 3}},
setreg={args={2, 3}},
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index ac28e3c3e0..25beb4be50 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -93,6 +93,7 @@ PRAGMA_DIAG_POP
static char *e_listarg = N_("E686: Argument of %s must be a List");
static char *e_stringreq = N_("E928: String required");
+static char *e_invalwindow = N_("E957: Invalid window number");
/// Dummy va_list for passing to vim_snprintf
///
@@ -952,12 +953,30 @@ static void f_cindent(typval_T *argvars, typval_T *rettv, FunPtr fptr)
rettv->vval.v_number = -1;
}
+static win_T * get_optional_window(typval_T *argvars, int idx)
+{
+ win_T *win = curwin;
+
+ if (argvars[idx].v_type != VAR_UNKNOWN) {
+ win = find_win_by_nr_or_id(&argvars[idx]);
+ if (win == NULL) {
+ EMSG(_(e_invalwindow));
+ return NULL;
+ }
+ }
+ return win;
+}
+
/*
* "clearmatches()" function
*/
static void f_clearmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
- clear_matches(curwin);
+ win_T *win = get_optional_window(argvars, 0);
+
+ if (win != NULL) {
+ clear_matches(win);
+ }
}
/*
@@ -3452,10 +3471,16 @@ static void f_getloclist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
*/
static void f_getmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
- matchitem_T *cur = curwin->w_match_head;
+ matchitem_T *cur;
int i;
+ win_T *win = get_optional_window(argvars, 0);
+
+ if (win == NULL) {
+ return;
+ }
tv_list_alloc_ret(rettv, kListLenMayKnow);
+ cur = win->w_match_head;
while (cur != NULL) {
dict_T *dict = tv_dict_alloc();
if (cur->match.regprog == NULL) {
@@ -5771,8 +5796,13 @@ static void f_matcharg(typval_T *argvars, typval_T *rettv, FunPtr fptr)
*/
static void f_matchdelete(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
- rettv->vval.v_number = match_delete(curwin,
- (int)tv_get_number(&argvars[0]), true);
+ win_T *win = get_optional_window(argvars, 1);
+ if (win == NULL) {
+ rettv->vval.v_number = -1;
+ } else {
+ rettv->vval.v_number = match_delete(win,
+ (int)tv_get_number(&argvars[0]), true);
+ }
}
/*
@@ -6393,20 +6423,14 @@ static void f_readdir(typval_T *argvars, typval_T *rettv, FunPtr fptr)
os_closedir(&dir);
}
- rettv->vval.v_list = tv_list_alloc(kListLenShouldKnow);
- if (rettv->vval.v_list != NULL) {
- tv_list_ref(rettv->vval.v_list);
+ if (rettv->vval.v_list != NULL && ga.ga_len > 0) {
sort_strings((char_u **)ga.ga_data, ga.ga_len);
for (int i = 0; i < ga.ga_len; i++) {
path = ((const char **)ga.ga_data)[i];
tv_list_append_string(rettv->vval.v_list, path, -1);
}
}
- for (int i = 0; i < ga.ga_len; i++) {
- xfree(((uint8_t **)ga.ga_data)[i]);
- }
-
- ga_clear(&ga);
+ ga_clear_strings(&ga);
}
/*
@@ -8142,14 +8166,19 @@ static void f_setloclist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
*/
static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
- dict_T *d;
- list_T *s = NULL;
+ dict_T *d;
+ list_T *s = NULL;
+ win_T *win = get_optional_window(argvars, 1);
rettv->vval.v_number = -1;
if (argvars[0].v_type != VAR_LIST) {
EMSG(_(e_listreq));
return;
}
+ if (win == NULL) {
+ return;
+ }
+
list_T *const l = argvars[0].vval.v_list;
// To some extent make sure that we are dealing with a list from
// "getmatches()".
@@ -8173,7 +8202,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
li_idx++;
});
- clear_matches(curwin);
+ clear_matches(win);
bool match_add_failed = false;
TV_LIST_ITER_CONST(l, li, {
int i = 0;
@@ -8219,13 +8248,13 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
? tv_get_string(&conceal_di->di_tv)
: NULL);
if (i == 0) {
- if (match_add(curwin, group,
+ if (match_add(win, group,
tv_dict_get_string(d, "pattern", false),
priority, id, NULL, conceal) != id) {
match_add_failed = true;
}
} else {
- if (match_add(curwin, group, NULL, priority, id, s, conceal) != id) {
+ if (match_add(win, group, NULL, priority, id, s, conceal) != id) {
match_add_failed = true;
}
tv_list_unref(s);
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 821227ec7a..7f4b01e306 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -1038,16 +1038,17 @@ static void profile_reset(void)
if (!HASHITEM_EMPTY(hi)) {
n--;
ufunc_T *uf = HI2UF(hi);
- if (uf->uf_profiling) {
+ if (uf->uf_prof_initialized) {
uf->uf_profiling = 0;
uf->uf_tm_count = 0;
uf->uf_tm_total = profile_zero();
uf->uf_tm_self = profile_zero();
uf->uf_tm_children = profile_zero();
- XFREE_CLEAR(uf->uf_tml_count);
- XFREE_CLEAR(uf->uf_tml_total);
- XFREE_CLEAR(uf->uf_tml_self);
+ for (int i = 0; i < uf->uf_lines.ga_len; i++) {
+ uf->uf_tml_count[i] = 0;
+ uf->uf_tml_total[i] = uf->uf_tml_self[i] = 0;
+ }
uf->uf_tml_start = profile_zero();
uf->uf_tml_children = profile_zero();
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index 7f17fb0035..fb277b25fd 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -398,10 +398,10 @@ int get_breakindent_win(win_T *wp, const char_u *line)
prev_tick = buf_get_changedtick(wp->w_buffer);
prev_indent = get_indent_str(line, (int)wp->w_buffer->b_p_ts, wp->w_p_list);
}
- bri = prev_indent + wp->w_p_brishift;
+ bri = prev_indent + wp->w_briopt_shift;
// indent minus the length of the showbreak string
- if (wp->w_p_brisbr) {
+ if (wp->w_briopt_sbr) {
bri -= vim_strsize(p_sbr);
}
// Add offset for number column, if 'n' is in 'cpoptions'
@@ -410,11 +410,11 @@ int get_breakindent_win(win_T *wp, const char_u *line)
// never indent past left window margin
if (bri < 0) {
bri = 0;
- } else if (bri > eff_wwidth - wp->w_p_brimin) {
+ } else if (bri > eff_wwidth - wp->w_briopt_min) {
// always leave at least bri_min characters on the left,
// if text width is sufficient
- bri = (eff_wwidth - wp->w_p_brimin < 0)
- ? 0 : eff_wwidth - wp->w_p_brimin;
+ bri = (eff_wwidth - wp->w_briopt_min < 0)
+ ? 0 : eff_wwidth - wp->w_briopt_min;
}
return bri;
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua
index fc337c5e7e..523d23ec12 100644
--- a/src/nvim/lua/vim.lua
+++ b/src/nvim/lua/vim.lua
@@ -332,9 +332,26 @@ do
return pcall_ret(pcall(fn, ...))
end
end
+
+ vim.b = make_meta_accessor(
+ nil_wrap(function(v) return a.nvim_buf_get_var(0, v) end),
+ function(v, k) return a.nvim_buf_set_var(0, v, k) end,
+ function(v) return a.nvim_buf_del_var(0, v) end
+ )
+ vim.w = make_meta_accessor(
+ nil_wrap(function(v) return a.nvim_win_get_var(0, v) end),
+ function(v, k) return a.nvim_win_set_var(0, v, k) end,
+ function(v) return a.nvim_win_del_var(0, v) end
+ )
+ vim.t = make_meta_accessor(
+ nil_wrap(function(v) return a.nvim_tabpage_get_var(0, v) end),
+ function(v, k) return a.nvim_tabpage_set_var(0, v, k) end,
+ function(v) return a.nvim_tabpage_del_var(0, v) end
+ )
vim.g = make_meta_accessor(nil_wrap(a.nvim_get_var), a.nvim_set_var, a.nvim_del_var)
vim.v = make_meta_accessor(nil_wrap(a.nvim_get_vvar), a.nvim_set_vvar)
vim.o = make_meta_accessor(a.nvim_get_option, a.nvim_set_option)
+
local function getenv(k)
local v = vim.fn.getenv(k)
if v == vim.NIL then
@@ -398,4 +415,67 @@ do
vim.wo = new_win_opt_accessor(nil)
end
+--- Get a table of lines with start, end columns for a region marked by two points
+---
+--@param bufnr number of buffer
+--@param pos1 (line, column) tuple marking beginning of region
+--@param pos2 (line, column) tuple marking end of region
+--@param regtype type of selection (:help setreg)
+--@param inclusive boolean indicating whether the selection is end-inclusive
+--@return region lua table of the form {linenr = {startcol,endcol}}
+function vim.region(bufnr, pos1, pos2, regtype, inclusive)
+ if not vim.api.nvim_buf_is_loaded(bufnr) then
+ vim.fn.bufload(bufnr)
+ end
+
+ -- in case of block selection, columns need to be adjusted for non-ASCII characters
+ -- TODO: handle double-width characters
+ local bufline
+ if regtype:byte() == 22 then
+ bufline = vim.api.nvim_buf_get_lines(bufnr, pos1[1], pos1[1] + 1, true)[1]
+ pos1[2] = vim.str_utfindex(bufline, pos1[2])
+ end
+
+ local region = {}
+ for l = pos1[1], pos2[1] do
+ local c1, c2
+ if regtype:byte() == 22 then -- block selection: take width from regtype
+ c1 = pos1[2]
+ c2 = c1 + regtype:sub(2)
+ -- and adjust for non-ASCII characters
+ bufline = vim.api.nvim_buf_get_lines(bufnr, l, l + 1, true)[1]
+ if c1 < #bufline then
+ c1 = vim.str_byteindex(bufline, c1)
+ end
+ if c2 < #bufline then
+ c2 = vim.str_byteindex(bufline, c2)
+ end
+ else
+ c1 = (l == pos1[1]) and (pos1[2]) or 0
+ c2 = (l == pos2[1]) and (pos2[2] + (inclusive and 1 or 0)) or -1
+ end
+ table.insert(region, l, {c1, c2})
+ end
+ return region
+end
+
+--- Defers calling `fn` until `timeout` ms passes.
+---
+--- Use to do a one-shot timer that calls `fn`
+--@param fn Callback to call once `timeout` expires
+--@param timeout Number of milliseconds to wait before calling `fn`
+--@return timer luv timer object
+function vim.defer_fn(fn, timeout)
+ vim.validate { fn = { fn, 'c', true}; }
+ local timer = vim.loop.new_timer()
+ timer:start(timeout, 0, vim.schedule_wrap(function()
+ timer:stop()
+ timer:close()
+
+ fn()
+ end))
+
+ return timer
+end
+
return module
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 4a9f2371a2..6ac9cdfbae 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -269,6 +269,8 @@ int main(int argc, char **argv)
early_init();
+ set_argv_var(argv, argc); // set v:argv
+
// Check if we have an interactive window.
check_and_set_isatty(&params);
diff --git a/src/nvim/message.c b/src/nvim/message.c
index a12e665099..9aa588e035 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -2574,10 +2574,15 @@ static int do_more_prompt(int typed_char)
msgchunk_T *mp;
int i;
+ // If headless mode is enabled and no input is required, this variable
+ // will be true. However If server mode is enabled, the message "--more--"
+ // should be displayed.
+ bool no_need_more = headless_mode && !embedded_mode;
+
// We get called recursively when a timer callback outputs a message. In
// that case don't show another prompt. Also when at the hit-Enter prompt
// and nothing was typed.
- if (entered || (State == HITRETURN && typed_char == 0)) {
+ if (no_need_more || entered || (State == HITRETURN && typed_char == 0)) {
return false;
}
entered = true;
diff --git a/src/nvim/move.c b/src/nvim/move.c
index d4f82bc601..8a8a639a52 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -996,7 +996,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp,
col -= wp->w_leftcol;
- if (col >= 0 && col < width) {
+ if (col >= 0 && col < wp->w_width) {
coloff = col - scol + (local ? 0 : wp->w_wincol) + 1;
} else {
scol = ccol = ecol = 0;
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 84ace55d91..96f8e1529a 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -7229,9 +7229,9 @@ static bool briopt_check(win_T *wp)
}
}
- wp->w_p_brishift = bri_shift;
- wp->w_p_brimin = bri_min;
- wp->w_p_brisbr = bri_sbr;
+ wp->w_briopt_shift = bri_shift;
+ wp->w_briopt_min = bri_min;
+ wp->w_briopt_sbr = bri_sbr;
return true;
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 8f8bfee60c..ba52f5b489 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -2966,11 +2966,11 @@ win_line (
}
}
- if (wp->w_p_brisbr && draw_state == WL_BRI - 1
+ if (wp->w_briopt_sbr && draw_state == WL_BRI - 1
&& n_extra == 0 && *p_sbr != NUL) {
// draw indent after showbreak value
draw_state = WL_BRI;
- } else if (wp->w_p_brisbr && draw_state == WL_SBR && n_extra == 0) {
+ } else if (wp->w_briopt_sbr && draw_state == WL_SBR && n_extra == 0) {
// after the showbreak, draw the breakindent
draw_state = WL_BRI - 1;
}
@@ -2994,7 +2994,13 @@ win_line (
c_final = NUL;
n_extra =
get_breakindent_win(wp, ml_get_buf(wp->w_buffer, lnum, false));
- if (wp->w_skipcol > 0 && wp->w_p_wrap) {
+ if (row == startrow) {
+ n_extra -= win_col_off2(wp);
+ if (n_extra < 0) {
+ n_extra = 0;
+ }
+ }
+ if (wp->w_skipcol > 0 && wp->w_p_wrap && wp->w_briopt_sbr) {
need_showbreak = false;
}
// Correct end of highlighted area for 'breakindent',
diff --git a/src/nvim/testdir/test_breakindent.vim b/src/nvim/testdir/test_breakindent.vim
index 6d88f1dc5a..a4c1f62a43 100644
--- a/src/nvim/testdir/test_breakindent.vim
+++ b/src/nvim/testdir/test_breakindent.vim
@@ -361,5 +361,64 @@ func Test_breakindent19_sbr_nextpage()
\ "> aaaaaaaaaaaaaaaaaa",
\ ]
call s:compare_lines(expect, lines)
+
+ setl breakindent briopt=min:18 sbr=>
+ norm! 5gj
+ let lines = s:screen_lines(1, 20)
+ let expect = [
+ \ ">aaaaaaaaaaaaaaaaaaa",
+ \ ">aaaaaaaaaaaaaaaaaaa",
+ \ ">aaaaaaaaaaaaaaaaaaa",
+ \ ]
+ call s:compare_lines(expect, lines)
call s:close_windows('set breakindent& briopt& sbr&')
endfunc
+
+func Test_breakindent20_cpo_n_nextpage()
+ let s:input = ""
+ call s:test_windows('setl breakindent briopt=min:14 cpo+=n number')
+ call setline(1, repeat('a', 200))
+ norm! 1gg
+ redraw!
+ let lines = s:screen_lines(1, 20)
+ let expect = [
+ \ " 1 aaaaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaaaa",
+ \ ]
+ call s:compare_lines(expect, lines)
+ " Scroll down one screen line
+ setl scrolloff=5
+ norm! 5gj
+ redraw!
+ let lines = s:screen_lines(1, 20)
+ let expect = [
+ \ "--1 aaaaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaaaa",
+ \ ]
+ call s:compare_lines(expect, lines)
+
+ setl briopt+=shift:2
+ norm! 1gg
+ let lines = s:screen_lines(1, 20)
+ let expect = [
+ \ " 1 aaaaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaa",
+ \ ]
+ call s:compare_lines(expect, lines)
+ " Scroll down one screen line
+ norm! 5gj
+ let lines = s:screen_lines(1, 20)
+ let expect = [
+ \ "--1 aaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaa",
+ \ ]
+ call s:compare_lines(expect, lines)
+
+ call s:close_windows('set breakindent& briopt& cpo& number&')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim
index e8e561dfd8..2e190911b2 100644
--- a/src/nvim/testdir/test_cursor_func.vim
+++ b/src/nvim/testdir/test_cursor_func.vim
@@ -93,3 +93,18 @@ func Test_screenpos()
close
bwipe!
endfunc
+
+func Test_screenpos_number()
+ rightbelow new
+ rightbelow 73vsplit
+ call setline (1, repeat('x', 66))
+ setlocal number
+ redraw
+ let winid = win_getid()
+ let [winrow, wincol] = win_screenpos(winid)
+ let pos = screenpos(winid, 1, 66)
+ call assert_equal(winrow, pos.row)
+ call assert_equal(wincol + 66 + 3, pos.col)
+ close
+ bwipe!
+endfunc
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index a9984acdd9..ace56a375f 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -321,6 +321,7 @@ let s:filename_checks = {
\ 'openroad': ['file.or'],
\ 'ora': ['file.ora'],
\ 'pamconf': ['/etc/pam.conf'],
+ \ 'pamenv': ['/etc/security/pam_env.conf', '/home/user/.pam_environment'],
\ 'papp': ['file.papp', 'file.pxml', 'file.pxsl'],
\ 'pascal': ['file.pas', 'file.dpr'],
\ 'passwd': ['any/etc/passwd', 'any/etc/passwd-', 'any/etc/passwd.edit', 'any/etc/shadow', 'any/etc/shadow-', 'any/etc/shadow.edit', 'any/var/backups/passwd.bak', 'any/var/backups/shadow.bak'],
diff --git a/src/nvim/testdir/test_match.vim b/src/nvim/testdir/test_match.vim
index c134cfb1c0..09448ca71b 100644
--- a/src/nvim/testdir/test_match.vim
+++ b/src/nvim/testdir/test_match.vim
@@ -149,6 +149,21 @@ function Test_match()
highlight MyGroup3 NONE
endfunc
+func Test_match_error()
+ call assert_fails('match Error', 'E475:')
+ call assert_fails('match Error /', 'E475:')
+ call assert_fails('4match Error /x/', 'E476:')
+ call assert_fails('match Error /x/ x', 'E488:')
+endfunc
+
+func Test_matchadd_error()
+ call assert_fails("call matchadd('GroupDoesNotExist', 'X')", 'E28:')
+ call assert_fails("call matchadd('Search', '\\(')", 'E475:')
+ call assert_fails("call matchadd('Search', 'XXX', 1, 123, 1)", 'E715:')
+ call assert_fails("call matchadd('Error', 'XXX', 1, 3)", 'E798:')
+ call assert_fails("call matchadd('Error', 'XXX', 1, 0)", 'E799:')
+endfunc
+
func Test_matchaddpos()
syntax on
set hlsearch
@@ -217,6 +232,19 @@ func Test_matchaddpos_otherwin()
call assert_equal(screenattr(1,2), screenattr(2,2))
call assert_notequal(screenattr(1,2), screenattr(1,4))
+ let savematches = getmatches(winid)
+ let expect = [
+ \ {'group': 'Search', 'pattern': '4', 'priority': 10, 'id': 4},
+ \ {'group': 'Error', 'id': 5, 'priority': 10, 'pos1': [1, 2, 1], 'pos2': [2, 2, 1]},
+ \]
+ call assert_equal(expect, savematches)
+
+ call clearmatches(winid)
+ call assert_equal([], getmatches(winid))
+
+ call setmatches(savematches, winid)
+ call assert_equal(expect, savematches)
+
wincmd w
bwipe!
call clearmatches()
@@ -250,6 +278,17 @@ func Test_matchaddpos_using_negative_priority()
set hlsearch&
endfunc
+func Test_matchaddpos_error()
+ call assert_fails("call matchaddpos('Error', 1)", 'E686:')
+ call assert_fails("call matchaddpos('Error', [1], 1, 1)", 'E798:')
+ call assert_fails("call matchaddpos('Error', [1], 1, 2)", 'E798:')
+ call assert_fails("call matchaddpos('Error', [1], 1, 0)", 'E799:')
+ call assert_fails("call matchaddpos('Error', [1], 1, 123, 1)", 'E715:')
+ call assert_fails("call matchaddpos('Error', [1], 1, 5, {'window':12345})", 'E957:')
+ " Why doesn't the following error have an error code E...?
+ call assert_fails("call matchaddpos('Error', [{}])", 'E5031:')
+endfunc
+
func OtherWindowCommon()
let lines =<< trim END
call setline(1, 'Hello Vim world')
@@ -275,6 +314,11 @@ func Test_matchdelete_other_window()
call delete('XscriptMatchCommon')
endfunc
+func Test_matchdelete_error()
+ call assert_fails("call matchdelete(0)", 'E802:')
+ call assert_fails("call matchdelete(1, -1)", 'E957:')
+endfunc
+
func Test_matchclear_other_window()
if !CanRunVimInTerminal()
throw 'Skipped: cannot make screendumps'
diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim
index 41f1710faf..400af33c58 100644
--- a/src/nvim/testdir/test_options.vim
+++ b/src/nvim/testdir/test_options.vim
@@ -42,6 +42,13 @@ function Test_wildchar()
set wildchar&
endfunction
+func Test_wildoptions()
+ set wildoptions=
+ set wildoptions+=tagfile
+ set wildoptions+=tagfile
+ call assert_equal('tagfile', &wildoptions)
+endfunc
+
function! Test_options()
let caught = 'ok'
try
diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim
index f03c493275..9abaca5957 100644
--- a/src/nvim/testdir/test_startup.vim
+++ b/src/nvim/testdir/test_startup.vim
@@ -584,3 +584,12 @@ func Test_start_with_tabs()
" clean up
call StopVimInTerminal(buf)
endfunc
+
+func Test_v_argv()
+ let out = system(GetVimCommand() . ' -es -V1 -X arg1 --cmd "echo v:argv" --cmd q')
+ let list = split(out, "', '")
+ call assert_match('vim', list[0])
+ let idx = index(list, 'arg1')
+ call assert_true(idx > 2)
+ call assert_equal(['arg1', '--cmd', 'echo v:argv', '--cmd', 'q'']'], list[idx:])
+endfunc