> > 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?
>
>
>
> Hi,
>
>
>
> I think you'll also need to patch runtime/syntax/vim.vim.
Thanks. I added it.
> It forces the user to look into the completion menu before continue typing.
Yes.
> Can you try providing use cases when which option is likely to be
preferred by users? Eg when do you want option "no selecetd candidate" ?
And this feature is useful for implementing auto completion plugin.
I implemented some auto completion plugins.
https://github.com/Shougo/neocomplete.vim
https://github.com/Shougo/neocomplcache.vim
And there are other completion plugins like YouCompleteMe.
https://github.com/Valloric/YouCompleteMe
They uses feedkeys() function like below.
call feedkeys( "\<C-X>\<C-U>\<C-P>", 'n' )
But default completion behavior(<C-x><C-u>) is annoying for me.
Because first candidate is selected automatically.
If the option is added, we can implement auto completion more easier.
--
--
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 44ca4bc7d747 runtime/doc/options.txt
--- a/runtime/doc/options.txt Wed May 29 22:58:32 2013 +0200
+++ b/runtime/doc/options.txt Thu May 30 15:22:17 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 44ca4bc7d747 runtime/doc/tags
--- a/runtime/doc/tags Wed May 29 22:58:32 2013 +0200
+++ b/runtime/doc/tags Thu May 30 15:22:17 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 44ca4bc7d747 runtime/syntax/vim.vim
--- a/runtime/syntax/vim.vim Wed May 29 22:58:32 2013 +0200
+++ b/runtime/syntax/vim.vim Thu May 30 15:22:17 2013 +0900
@@ -31,7 +31,7 @@
syn keyword vimOption contained ai ambw ari aw backupext beval biosk brk buflisted cdpath cin cinwords cocu compatible consk cpt cscopetag cst cursorline dex digraph ead ei equalalways eventignore fde fdt fileencoding fkmap foldenable foldminlines formatprg gdefault gp guifontset helpfile hidden hl ignorecase imdisable includeexpr inf isident key langmap lines lmap ma matchtime mco ml modeline mousefocus mousetime nrformats ofu para pdev pi previewwindow printmbfont qe report rlc ruler scb scs sessionoptions shellquote shiftround showfulltag sidescrolloff smarttab sp spf srr startofline suffixes switchbuf ta tagrelative tbis textauto timeout tm tr ttm ttyscroll udir updatecount vdir viewdir wa wd wi wildignorecase window winwidth wmw writeany
syn keyword vimOption contained akm anti arshape awa backupskip bex bioskey browsedir buftype cedit cindent clipboard cole complete conskey crb cscopetagorder csto cwh dg dip eadirection ek equalprg ex fdi fen fileencodings flp foldexpr foldnestmax fp gfm grepformat guifontwide helpheight highlight hlg im imi incsearch infercase isk keymap langmenu linespace loadplugins macatsui maxcombine mef mls modelines mousehide mp nu omnifunc paragraphs penc pm printdevice printoptions quoteescape restorescreen rnu rulerformat scr sect sft shellredir shiftwidth showmatch siso smc spc spl ss statusline suffixesadd sws tabline tags tbs textmode timeoutlen to ts tty ttytype ul updatetime ve viewoptions wak weirdinvert wic wildmenu winfixheight wiv wop writebackup
syn keyword vimOption contained al antialias autochdir background balloondelay bexpr bk bs casemap cf cink cmdheight colorcolumn completefunc copyindent cryptmethod cscopeverbose csverb debug dict dir eb enc errorbells expandtab fdl fenc fileformat fml foldignore foldopen fs gfn grepprg guiheadroom helplang history hls imactivatekey iminsert inde insertmode iskeyword keymodel laststatus lisp lpl magic maxfuncdepth menuitems mm modifiable mousem mps number opendevice paste pex pmbcs printencoding prompt rdt revins ro runtimepath scroll sections sh shellslash shm showmode sj smd spell splitbelow ssl stl sw sxe tabpagemax tagstack tenc textwidth title toolbar tsl ttybuiltin tw undodir ur verbose viminfo warn wfh wig wildmode winfixwidth wiw wrap writedelay
-syn keyword vimOption contained aleph ar autoindent backspace ballooneval bg bkc bsdir cb cfu cinkeys cmdwinheight columns completeopt cot cscopepathcomp cspc cuc deco dictionary directory ed encoding errorfile exrc fdls fencs fileformats fmr foldlevel foldtext fsync gfs gtl guioptions hf hk hlsearch imak ims indentexpr is isp keywordprg lazyredraw lispwords ls makeef maxmapdepth mfd mmd modified mousemodel msm numberwidth operatorfunc pastetoggle pexpr pmbfn printexpr pt readonly ri rs sb scrollbind secure shcf shelltemp shortmess showtabline slm sn spellcapcheck splitright ssop stmp swapfile sxq tabstop tal term tf titlelen toolbariconsize tsr ttyfast tx undofile ut verbosefile virtualedit wb wfw wildchar wildoptions winheight wm wrapmargin ws
+syn keyword vimOption contained aleph ar autoindent backspace ballooneval bg bkc bsdir cb cfu cinkeys cmdwinheight columns completeopt cot completeselect cselect cscopepathcomp cspc cuc deco dictionary directory ed encoding errorfile exrc fdls fencs fileformats fmr foldlevel foldtext fsync gfs gtl guioptions hf hk hlsearch imak ims indentexpr is isp keywordprg lazyredraw lispwords ls makeef maxmapdepth mfd mmd modified mousemodel msm numberwidth operatorfunc pastetoggle pexpr pmbfn printexpr pt readonly ri rs sb scrollbind secure shcf shelltemp shortmess showtabline slm sn spellcapcheck splitright ssop stmp swapfile sxq tabstop tal term tf titlelen toolbariconsize tsr ttyfast tx undofile ut verbosefile virtualedit wb wfw wildchar wildoptions winheight wm wrapmargin ws
syn keyword vimOption contained allowrevins arab autoread backup balloonexpr bh bl bsk cc ch cino cmp com concealcursor cp cscopeprg csprg cul def diff display edcompatible endofline errorformat fcl fdm fex filetype fo foldlevelstart formatexpr ft gfw gtt guipty hh hkmap ic imc imsearch indentkeys isf isprint km lbr list lsp makeprg maxmem mh mmp more mouses mzq nuw opfunc patchexpr pfn popt printfont pumheight redrawtime rightleft rtp sbo scrolljump sel shell shelltype shortname shq sm so spellfile spr st sts swapsync syn tag tb termbidi tgst titleold top ttimeout ttym uc undolevels vb vfile visualbell wc wh wildcharm wim winminheight wmh wrapscan ww
syn keyword vimOption contained altkeymap arabic autowrite backupcopy bdir bin bomb bt ccv charconvert cinoptions cms comments conceallevel cpo cscopequickfix csqf cursorbind define diffexpr dy ef eol esckeys fcs fdn ff fillchars foldclose foldmarker formatlistpat gcr ghr guicursor guitablabel hi hkmapp icon imcmdline inc indk isfname joinspaces kmp lcs listchars lw mat maxmempattern mis mmt mouse mouseshape mzquantum odev osfiletype patchmode ph preserveindent printheader pvh relativenumber rightleftcmd ru sbr scrolloff selection shellcmdflag shellxescape showbreak si smartcase softtabstop spelllang sps sta su swb synmaxcol tagbsearch tbi termencoding thesaurus titlestring
diff -r 44ca4bc7d747 src/edit.c
--- a/src/edit.c Wed May 29 22:58:32 2013 +0200
+++ b/src/edit.c Thu May 30 15:22:17 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 44ca4bc7d747 src/option.c
--- a/src/option.c Wed May 29 22:58:32 2013 +0200
+++ b/src/option.c Thu May 30 15:22:17 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 44ca4bc7d747 src/option.h
--- a/src/option.h Wed May 29 22:58:32 2013 +0200
+++ b/src/option.h Thu May 30 15:22:17 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' */