aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-03-13 08:27:37 -0500
committerGitHub <noreply@github.com>2021-03-13 08:27:37 -0500
commit5d5e018a5c1a8f0f185718dd4513b908c164a6b9 (patch)
treec65c1e34c4ea4a51c9467797858e7fad6ac34e0f
parentd38508d88ab78415368bce350072f9f0f73c15d2 (diff)
parenta4ea6027880211b15b5659054e6e14d384517e27 (diff)
downloadrneovim-5d5e018a5c1a8f0f185718dd4513b908c164a6b9.tar.gz
rneovim-5d5e018a5c1a8f0f185718dd4513b908c164a6b9.tar.bz2
rneovim-5d5e018a5c1a8f0f185718dd4513b908c164a6b9.zip
Merge pull request #14125 from janlazo/vim-8.2.2591
vim-patch:8.2.{2341,2452,2591}
-rw-r--r--runtime/filetype.vim3
-rw-r--r--src/nvim/eval.c3
-rw-r--r--src/nvim/eval/funcs.c6
-rw-r--r--src/nvim/ex_getln.c13
-rw-r--r--src/nvim/option.c8
-rw-r--r--src/nvim/options.lua1
-rw-r--r--src/nvim/testdir/test_cmdline.vim15
-rw-r--r--src/nvim/testdir/test_filetype.vim1
-rw-r--r--src/nvim/testdir/test_options.vim7
9 files changed, 54 insertions, 3 deletions
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 6a13e67ac5..4130db2534 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1330,6 +1330,9 @@ au BufNewFile,BufRead *.pml setf promela
au BufNewFile,BufRead *.proto setf proto
au BufNewFile,BufRead *.pbtxt setf pbtxt
+" Poke
+au BufNewFile,BufRead *.pk setf poke
+
" Protocols
au BufNewFile,BufRead */etc/protocols setf protocols
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 63d5216cc4..f190ef14c4 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -3007,7 +3007,8 @@ static size_t varnamebuflen = 0;
/*
* Function to concatenate a prefix and a variable name.
*/
-static char_u *cat_prefix_varname(int prefix, char_u *name)
+char_u *cat_prefix_varname(int prefix, const char_u *name)
+ FUNC_ATTR_NONNULL_ALL
{
size_t len = STRLEN(name) + 3;
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 25784c240f..2b04469af7 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -117,8 +117,12 @@ char_u *get_function_name(expand_T *xp, int idx)
intidx = -1;
if (intidx < 0) {
name = get_user_func_name(xp, idx);
- if (name != NULL)
+ if (name != NULL) {
+ if (*name != '<' && STRNCMP("g:", xp->xp_pattern, 2) == 0) {
+ return cat_prefix_varname('g', name);
+ }
return name;
+ }
}
while ((size_t)++intidx < ARRAY_SIZE(functions)
&& functions[intidx].name[0] == '\0') {
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 5979f4d3a0..9977be56ca 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -5117,6 +5117,18 @@ ExpandFromContext (
if (xp->xp_context == EXPAND_PACKADD) {
return ExpandPackAddDir(pat, num_file, file);
}
+
+ // When expanding a function name starting with s:, match the <SNR>nr_
+ // prefix.
+ char_u *tofree = NULL;
+ if (xp->xp_context == EXPAND_USER_FUNC && STRNCMP(pat, "^s:", 3) == 0) {
+ const size_t len = STRLEN(pat) + 20;
+
+ tofree = xmalloc(len);
+ snprintf((char *)tofree, len, "^<SNR>\\d\\+_%s", pat + 3);
+ pat = tofree;
+ }
+
if (xp->xp_context == EXPAND_LUA) {
ILOG("PAT %s", pat);
return nlua_expand_pat(xp, pat, num_file, file);
@@ -5195,6 +5207,7 @@ ExpandFromContext (
}
vim_regfree(regmatch.regprog);
+ xfree(tofree);
return ret;
}
diff --git a/src/nvim/option.c b/src/nvim/option.c
index ac25c86b5f..dbd8ceb55c 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -2086,9 +2086,12 @@ int was_set_insecurely(win_T *const wp, char_u *opt, int opt_flags)
/// Get a pointer to the flags used for the P_INSECURE flag of option
/// "opt_idx". For some local options a local flags field is used.
+/// NOTE: Caller must make sure that "wp" is set to the window from which
+/// the option is used.
static uint32_t *insecure_flag(win_T *const wp, int opt_idx, int opt_flags)
{
- if (opt_flags & OPT_LOCAL)
+ if (opt_flags & OPT_LOCAL) {
+ assert(wp != NULL);
switch ((int)options[opt_idx].indir) {
case PV_STL: return &wp->w_p_stl_flags;
case PV_FDE: return &wp->w_p_fde_flags;
@@ -2097,6 +2100,7 @@ static uint32_t *insecure_flag(win_T *const wp, int opt_idx, int opt_flags)
case PV_FEX: return &wp->w_buffer->b_p_fex_flags;
case PV_INEX: return &wp->w_buffer->b_p_inex_flags;
}
+ }
// Nothing special, return global flags field.
return &options[opt_idx].flags;
@@ -6178,6 +6182,8 @@ set_context_in_set_cmd(
xp->xp_backslash = XP_BS_THREE;
else
xp->xp_backslash = XP_BS_ONE;
+ } else if (p == (char_u *)&p_ft) {
+ xp->xp_context = EXPAND_FILETYPE;
} else {
xp->xp_context = EXPAND_FILES;
// for 'tags' need three backslashes for a space
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index fe108ef1cc..f4c1ac9131 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -900,6 +900,7 @@ return {
normal_fname_chars=true,
vi_def=true,
alloced=true,
+ expand=true,
varname='p_ft',
defaults={if_true={vi=""}}
},
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index a66aee5e02..489b2477e6 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -569,6 +569,21 @@ func Test_cmdline_complete_user_cmd()
delcommand Foo
endfunc
+func s:ScriptLocalFunction()
+ echo 'yes'
+endfunc
+
+func Test_cmdline_complete_user_func()
+ call feedkeys(":func Test_cmdline_complete_user\<Tab>\<Home>\"\<cr>", 'tx')
+ call assert_match('"func Test_cmdline_complete_user', @:)
+ call feedkeys(":func s:ScriptL\<Tab>\<Home>\"\<cr>", 'tx')
+ call assert_match('"func <SNR>\d\+_ScriptLocalFunction', @:)
+
+ " g: prefix also works
+ call feedkeys(":echo g:Test_cmdline_complete_user_f\<Tab>\<Home>\"\<cr>", 'tx')
+ call assert_match('"echo g:Test_cmdline_complete_user_func', @:)
+endfunc
+
func Test_cmdline_complete_user_names()
if has('unix') && executable('whoami')
let whoami = systemlist('whoami')[0]
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index 6bc5fba5db..76e5de7df9 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -358,6 +358,7 @@ let s:filename_checks = {
\ 'po': ['file.po', 'file.pot'],
\ 'pod': ['file.pod'],
\ 'pod6': ['file.pod6'],
+ \ 'poke': ['file.pk'],
\ 'postscr': ['file.ps', 'file.pfa', 'file.afm', 'file.eps', 'file.epsf', 'file.epsi', 'file.ai'],
\ 'pov': ['file.pov'],
\ 'povini': ['.povrayrc'],
diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim
index 1202b842fd..05564d2ce8 100644
--- a/src/nvim/testdir/test_options.vim
+++ b/src/nvim/testdir/test_options.vim
@@ -230,6 +230,13 @@ func Test_set_completion()
call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
set tags&
+
+ " Expand values for 'filetype'
+ call feedkeys(":set filetype=sshdconfi\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set filetype=sshdconfig', @:)
+ call feedkeys(":set filetype=a\<C-A>\<C-B>\"\<CR>", 'xt')
+ " call assert_equal('"set filetype=' .. getcompletion('a*', 'filetype')->join(), @:)
+ call assert_equal('"set filetype=' .. join(getcompletion('a*', 'filetype')), @:)
endfunc
func Test_set_errors()