Hello.
I developed "completeselect" option feature in Vim.
It determines how to select candidate in ins-completion.
The possible values are:
0 select and insert first candidate
1 select first candidate but not insert
2 no selected candidate
I think it is good change for completion.
I tested it in Vim 7.3.1036 and it worked fine.
How do you think about this feature?
--
--
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/groups/opt_out.
diff -r 73c04954a835 runtime/doc/options.txt
--- a/runtime/doc/options.txt Sun May 26 23:13:07 2013 +0200
+++ b/runtime/doc/options.txt Mon May 27 16:57:42 2013 +0900
@@ -1785,6 +1785,19 @@
completion in the preview window. Only works in
combination with "menu" or "menuone".
+'completeselect' 'cselect' *'completeselect'* *'cselect'*
+ number (default 0)
+ global
+ {not in Vi}
+ {not available when compiled without the
+ |+insert_expand| feature}
+
+ Determine how to select candidate in |ins-completion|.
+ The possible values are:
+ 0 select and insert first candidate
+ 1 select first candidate but not insert
+ 2 no selected candidate
+ Note If the option is changed, it may affect auto completion plugins.
*'concealcursor'* *'cocu'*
'concealcursor' 'cocu' string (default: "")
diff -r 73c04954a835 runtime/doc/tags
--- a/runtime/doc/tags Sun May 26 23:13:07 2013 +0200
+++ b/runtime/doc/tags Mon May 27 16:57:42 2013 +0900
@@ -138,6 +138,7 @@
'complete' options.txt /*'complete'*
'completefunc' options.txt /*'completefunc'*
'completeopt' options.txt /*'completeopt'*
+'completeselect' options.txt /*'completeselect'*
'concealcursor' options.txt /*'concealcursor'*
'conceallevel' options.txt /*'conceallevel'*
'confirm' options.txt /*'confirm'*
@@ -158,6 +159,7 @@
'cscopetag' options.txt /*'cscopetag'*
'cscopetagorder' options.txt /*'cscopetagorder'*
'cscopeverbose' options.txt /*'cscopeverbose'*
+'cselect' options.txt /*'cselect'*
'cspc' options.txt /*'cspc'*
'csprg' options.txt /*'csprg'*
'csqf' options.txt /*'csqf'*
diff -r 73c04954a835 src/edit.c
--- a/src/edit.c Sun May 26 23:13:07 2013 +0200
+++ b/src/edit.c Mon May 27 16:57:42 2013 +0900
@@ -2882,7 +2882,7 @@
colnr_T col;
int lead_len = 0;
- if (!pum_wanted() || !pum_enough_matches())
+ if (!pum_wanted() || (!pum_enough_matches() && p_cselect == 0))
return;
#if defined(FEAT_EVAL)
@@ -4622,6 +4622,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. */
@@ -4703,7 +4704,7 @@
return -1;
}
- if (advance)
+ if (p_cselect != 2 && advance)
{
if (compl_shows_dir == BACKWARD)
--compl_pending;
@@ -4755,7 +4756,11 @@
}
/* Insert the text of the new completion, or the compl_leader. */
- if (insert_match)
+ if (p_cselect == 1 && !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();
@@ -4792,7 +4797,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 (p_cselect == 1 && !started)
+ compl_enter_selects = TRUE;
+ else
+ compl_enter_selects = !insert_match && compl_match_array != NULL;
/*
* Show the file name for the match (if any)
@@ -4867,7 +4875,7 @@
}
}
}
- if (compl_pending != 0 && !got_int)
+ if (compl_pending != 0 && !got_int && p_cselect != 1)
{
int todo = compl_pending > 0 ? compl_pending : -compl_pending;
diff -r 73c04954a835 src/option.c
--- a/src/option.c Sun May 26 23:13:07 2013 +0200
+++ b/src/option.c Mon May 27 16:57:42 2013 +0900
@@ -848,6 +848,13 @@
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
+ {"completeselect", "cselect", P_NUM|P_RWIN|P_VI_DEF,
+#ifdef FEAT_INS_EXPAND
+ (char_u *)&p_cselect, PV_NONE,
+#else
+ (char_u *)NULL, PV_NONE,
+#endif
+ {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
{"confirm", "cf", P_BOOL|P_VI_DEF,
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
(char_u *)&p_confirm, PV_NONE,
diff -r 73c04954a835 src/option.h
--- a/src/option.h Sun May 26 23:13:07 2013 +0200
+++ b/src/option.h Mon May 27 16:57:42 2013 +0900
@@ -390,6 +390,7 @@
EXTERN int p_cp; /* 'compatible' */
#ifdef FEAT_INS_EXPAND
EXTERN char_u *p_cot; /* 'completeopt' */
+EXTERN long p_cselect; /* 'completeselect' */
EXTERN long p_ph; /* 'pumheight' */
#endif
EXTERN char_u *p_cpo; /* 'cpoptions' */