mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #19962 from zeertzjq/vim-9.0.0278
vim-patch:9.0.{0278,0279,0283,0284}: cmdline completion patches
This commit is contained in:
commit
58b29e344c
@ -6940,12 +6940,15 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
*'wildmenu'* *'wmnu'* *'nowildmenu'* *'nowmnu'*
|
*'wildmenu'* *'wmnu'* *'nowildmenu'* *'nowmnu'*
|
||||||
'wildmenu' 'wmnu' boolean (default on)
|
'wildmenu' 'wmnu' boolean (default on)
|
||||||
global
|
global
|
||||||
Enables "enhanced mode" of command-line completion. When user hits
|
When 'wildmenu' is on, command-line completion operates in an enhanced
|
||||||
<Tab> (or 'wildchar') to invoke completion, the possible matches are
|
mode. On pressing 'wildchar' (usually <Tab>) to invoke completion,
|
||||||
shown in a menu just above the command-line (see 'wildoptions'), with
|
the possible matches are shown.
|
||||||
the first match highlighted (overwriting the statusline). Keys that
|
When 'wildoptions' contains "pum", then the completion matches are
|
||||||
show the previous/next match (<Tab>/CTRL-P/CTRL-N) highlight the
|
shown in a popup menu. Otherwise they are displayed just above the
|
||||||
match.
|
command line, with the first match highlighted (overwriting the status
|
||||||
|
line, if there is one).
|
||||||
|
Keys that show the previous/next match, such as <Tab> or
|
||||||
|
CTRL-P/CTRL-N, cause the highlight to move to the appropriate match.
|
||||||
'wildmode' must specify "full": "longest" and "list" do not start
|
'wildmode' must specify "full": "longest" and "list" do not start
|
||||||
'wildmenu' mode. You can check the current mode with |wildmenumode()|.
|
'wildmenu' mode. You can check the current mode with |wildmenumode()|.
|
||||||
The menu is canceled when a key is hit that is not used for selecting
|
The menu is canceled when a key is hit that is not used for selecting
|
||||||
|
@ -90,14 +90,14 @@ static char *(history_names[]) = {
|
|||||||
/// arguments of the ":history command.
|
/// arguments of the ":history command.
|
||||||
char *get_history_arg(expand_T *xp, int idx)
|
char *get_history_arg(expand_T *xp, int idx)
|
||||||
{
|
{
|
||||||
static char_u compl[2] = { NUL, NUL };
|
const char *short_names = ":=@>?/";
|
||||||
char *short_names = ":=@>?/";
|
const int short_names_count = (int)STRLEN(short_names);
|
||||||
int short_names_count = (int)STRLEN(short_names);
|
const int history_name_count = ARRAY_SIZE(history_names) - 1;
|
||||||
int history_name_count = ARRAY_SIZE(history_names) - 1;
|
|
||||||
|
|
||||||
if (idx < short_names_count) {
|
if (idx < short_names_count) {
|
||||||
compl[0] = (char_u)short_names[idx];
|
xp->xp_buf[0] = short_names[idx];
|
||||||
return (char *)compl;
|
xp->xp_buf[1] = NUL;
|
||||||
|
return xp->xp_buf;
|
||||||
}
|
}
|
||||||
if (idx < short_names_count + history_name_count) {
|
if (idx < short_names_count + history_name_count) {
|
||||||
return history_names[idx - short_names_count];
|
return history_names[idx - short_names_count];
|
||||||
|
@ -237,6 +237,8 @@ struct expand {
|
|||||||
int xp_col; // cursor position in line
|
int xp_col; // cursor position in line
|
||||||
char **xp_files; // list of files
|
char **xp_files; // list of files
|
||||||
char *xp_line; // text being completed
|
char *xp_line; // text being completed
|
||||||
|
#define EXPAND_BUF_LEN 256
|
||||||
|
char xp_buf[EXPAND_BUF_LEN]; // buffer for returned match
|
||||||
};
|
};
|
||||||
|
|
||||||
// values for xp_backslash
|
// values for xp_backslash
|
||||||
|
@ -1808,6 +1808,7 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
// menu (if present)
|
// menu (if present)
|
||||||
cmdline_pum_cleanup(&ccline);
|
cmdline_pum_cleanup(&ccline);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextwild(&s->xpc, WILD_ALL, 0, s->firstc != '@') == FAIL) {
|
if (nextwild(&s->xpc, WILD_ALL, 0, s->firstc != '@') == FAIL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,9 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
|
|||||||
curbuf->b_op_start = orig_start;
|
curbuf->b_op_start = orig_start;
|
||||||
|
|
||||||
if (flags & READ_NOFILE) {
|
if (flags & READ_NOFILE) {
|
||||||
return NOTDONE; // so that BufEnter can be triggered
|
// Return NOTDONE instead of FAIL so that BufEnter can be triggered
|
||||||
|
// and other operations don't fail.
|
||||||
|
return NOTDONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,15 +1156,12 @@ char *home_replace_save(buf_T *buf, const char *src)
|
|||||||
/// Function given to ExpandGeneric() to obtain an environment variable name.
|
/// Function given to ExpandGeneric() to obtain an environment variable name.
|
||||||
char *get_env_name(expand_T *xp, int idx)
|
char *get_env_name(expand_T *xp, int idx)
|
||||||
{
|
{
|
||||||
#define ENVNAMELEN 100
|
|
||||||
// this static buffer is needed to avoid a memory leak in ExpandGeneric
|
|
||||||
static char_u name[ENVNAMELEN];
|
|
||||||
assert(idx >= 0);
|
assert(idx >= 0);
|
||||||
char *envname = os_getenvname_at_index((size_t)idx);
|
char *envname = os_getenvname_at_index((size_t)idx);
|
||||||
if (envname) {
|
if (envname) {
|
||||||
STRLCPY(name, envname, ENVNAMELEN);
|
STRLCPY(xp->xp_buf, envname, EXPAND_BUF_LEN);
|
||||||
xfree(envname);
|
xfree(envname);
|
||||||
return (char *)name;
|
return xp->xp_buf;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -5665,6 +5665,7 @@ static enum {
|
|||||||
EXP_CASE, // expand ":syn case" arguments
|
EXP_CASE, // expand ":syn case" arguments
|
||||||
EXP_SPELL, // expand ":syn spell" arguments
|
EXP_SPELL, // expand ":syn spell" arguments
|
||||||
EXP_SYNC, // expand ":syn sync" arguments
|
EXP_SYNC, // expand ":syn sync" arguments
|
||||||
|
EXP_CLUSTER, // expand ":syn list @cluster" arguments
|
||||||
} expand_what;
|
} expand_what;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5712,10 +5713,16 @@ void set_context_in_syntax_cmd(expand_T *xp, const char *arg)
|
|||||||
expand_what = EXP_SPELL;
|
expand_what = EXP_SPELL;
|
||||||
} else if (STRNICMP(arg, "sync", p - arg) == 0) {
|
} else if (STRNICMP(arg, "sync", p - arg) == 0) {
|
||||||
expand_what = EXP_SYNC;
|
expand_what = EXP_SYNC;
|
||||||
|
} else if (STRNICMP(arg, "list", p - arg) == 0) {
|
||||||
|
p = skipwhite(p);
|
||||||
|
if (*p == '@') {
|
||||||
|
expand_what = EXP_CLUSTER;
|
||||||
|
} else {
|
||||||
|
xp->xp_context = EXPAND_HIGHLIGHT;
|
||||||
|
}
|
||||||
} else if (STRNICMP(arg, "keyword", p - arg) == 0
|
} else if (STRNICMP(arg, "keyword", p - arg) == 0
|
||||||
|| STRNICMP(arg, "region", p - arg) == 0
|
|| STRNICMP(arg, "region", p - arg) == 0
|
||||||
|| STRNICMP(arg, "match", p - arg) == 0
|
|| STRNICMP(arg, "match", p - arg) == 0) {
|
||||||
|| STRNICMP(arg, "list", p - arg) == 0) {
|
|
||||||
xp->xp_context = EXPAND_HIGHLIGHT;
|
xp->xp_context = EXPAND_HIGHLIGHT;
|
||||||
} else {
|
} else {
|
||||||
xp->xp_context = EXPAND_NOTHING;
|
xp->xp_context = EXPAND_NOTHING;
|
||||||
@ -5749,6 +5756,14 @@ char *get_syntax_name(expand_T *xp, int idx)
|
|||||||
"maxlines=", "minlines=", "region", NULL };
|
"maxlines=", "minlines=", "region", NULL };
|
||||||
return sync_args[idx];
|
return sync_args[idx];
|
||||||
}
|
}
|
||||||
|
case EXP_CLUSTER:
|
||||||
|
if (idx < curwin->w_s->b_syn_clusters.ga_len) {
|
||||||
|
vim_snprintf(xp->xp_buf, EXPAND_BUF_LEN, "@%s",
|
||||||
|
SYN_CLSTR(curwin->w_s)[idx].scl_name);
|
||||||
|
return xp->xp_buf;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -198,6 +198,10 @@ func Test_syntax_completion()
|
|||||||
|
|
||||||
call feedkeys(":syn match \<C-A>\<C-B>\"\<CR>", 'tx')
|
call feedkeys(":syn match \<C-A>\<C-B>\"\<CR>", 'tx')
|
||||||
call assert_match('^"syn match @boolean @character ', @:)
|
call assert_match('^"syn match @boolean @character ', @:)
|
||||||
|
|
||||||
|
syn cluster Aax contains=Aap
|
||||||
|
call feedkeys(":syn list @A\<C-A>\<C-B>\"\<CR>", 'tx')
|
||||||
|
call assert_match('^"syn list @Aax', @:)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_echohl_completion()
|
func Test_echohl_completion()
|
||||||
|
Loading…
Reference in New Issue
Block a user