Hi, Bram.
I updated the completeopt patch.
It supports complete().
Please include it.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff -r ee39b0c5d55e runtime/doc/options.txt
--- a/runtime/doc/options.txt Wed Jun 10 12:16:47 2015 +0200
+++ b/runtime/doc/options.txt Fri Jun 12 11:53:31 2015 +0900
@@ -1819,6 +1819,14 @@
completion in the preview window. Only works in
combination with "menu" or "menuone".
+ noinsert Do not insert any text for a match until the user selects
+ a match from the menu. Only works in combination with "menu"
+ or "menuone". No effect if "longest" is present.
+
+ noselect Do not select a match in the menu, force the user to
+ select one from the menu. Only works in combination with "menu"
+ or "menuone".
+
*'concealcursor'* *'cocu'*
'concealcursor' 'cocu' string (default: "")
diff -r ee39b0c5d55e src/edit.c
--- a/src/edit.c Wed Jun 10 12:16:47 2015 +0200
+++ b/src/edit.c Fri Jun 12 11:53:31 2015 +0900
@@ -108,6 +108,11 @@
static int compl_get_longest = FALSE; /* put longest common string
in compl_leader */
+static int compl_no_insert = FALSE; /* FALSE: select & insert
+ TRUE: noinsert */
+static int compl_no_select = FALSE; /* FALSE: select & insert
+ TRUE: noselect */
+
static int compl_used_match; /* Selected one of the matches. When
FALSE the match was edited or using
the longest common string. */
@@ -2788,7 +2793,18 @@
compl_cont_status = 0;
compl_curr_match = compl_first_match;
- ins_complete(Ctrl_N);
+ if (compl_no_insert)
+ {
+ ins_complete(K_DOWN);
+ }
+ else
+ {
+ ins_complete(Ctrl_N);
+ if (compl_no_select)
+ {
+ ins_complete(Ctrl_P);
+ }
+ }
out_flush();
}
@@ -3655,8 +3671,25 @@
if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET
|| (ctrl_x_mode == 0 && !compl_started))
{
- compl_get_longest = (vim_strchr(p_cot, 'l') != NULL);
+ compl_get_longest = (strstr((char *)p_cot, "longest") != NULL);
compl_used_match = TRUE;
+
+ }
+
+ if (strstr((char *)p_cot, "noselect") != NULL)
+ {
+ compl_no_insert = FALSE;
+ compl_no_select = TRUE;
+ }
+ else if (strstr((char *)p_cot, "noinsert") != NULL)
+ {
+ compl_no_insert = TRUE;
+ compl_no_select = FALSE;
+ }
+ else
+ {
+ compl_no_insert = FALSE;
+ compl_no_select = FALSE;
}
if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET)
@@ -4648,6 +4681,7 @@
compl_T *found_compl = NULL;
int found_end = FALSE;
int advance;
+ int started = compl_started;
/* When user complete function return -1 for findstart which is next
* time of 'always', compl_shown_match become NULL. */
@@ -4729,7 +4763,7 @@
return -1;
}
- if (advance)
+ if (!compl_no_select && advance)
{
if (compl_shows_dir == BACKWARD)
--compl_pending;
@@ -4781,7 +4815,11 @@
}
/* Insert the text of the new completion, or the compl_leader. */
- if (insert_match)
+ if (compl_no_insert && !started) {
+ ins_bytes(compl_orig_text + ins_compl_len());
+ compl_used_match = FALSE;
+ }
+ else if (insert_match)
{
if (!compl_get_longest || compl_used_match)
ins_compl_insert();
@@ -4818,7 +4856,10 @@
/* Enter will select a match when the match wasn't inserted and the popup
* menu is visible. */
- compl_enter_selects = !insert_match && compl_match_array != NULL;
+ if (compl_no_insert && !started)
+ compl_enter_selects = TRUE;
+ else
+ compl_enter_selects = !insert_match && compl_match_array != NULL;
/*
* Show the file name for the match (if any)
@@ -4893,7 +4934,7 @@
}
}
}
- if (compl_pending != 0 && !got_int)
+ if (compl_pending != 0 && !got_int && !compl_no_insert)
{
int todo = compl_pending > 0 ? compl_pending : -compl_pending;
diff -r ee39b0c5d55e src/option.c
--- a/src/option.c Wed Jun 10 12:16:47 2015 +0200
+++ b/src/option.c Fri Jun 12 11:53:31 2015 +0900
@@ -3039,7 +3039,7 @@
static char *(p_fcl_values[]) = {"all", NULL};
#endif
#ifdef FEAT_INS_EXPAND
-static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", NULL};
+static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
#endif
static void set_option_default __ARGS((int, int opt_flags, int compatible));