Skip to content

Make autoselection of first completion item configurable #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions autoload/acp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,16 @@ function acp#onPopupPost()
if pumvisible()
inoremap <silent> <expr> <C-h> acp#onBs()
inoremap <silent> <expr> <BS> acp#onBs()
let l:autoselect_up = ""
let l:autoselect_down = ""
if g:acp_autoselectFirstCompletion
let l:autoselect_up = "\<Up>"
let l:autoselect_down = "\<Down>"
endif
" a command to restore to original text and select the first match
return (s:behavsCurrent[s:iBehavs].command =~# "\<C-p>" ? "\<C-n>\<Up>"
\ : "\<C-p>\<Down>")
return (s:behavsCurrent[s:iBehavs].command =~# "\<C-p>"
\ ? "\<C-n>" . l:autoselect_up
\ : "\<C-p>" . l:autoselect_down)
endif
let s:iBehavs += 1
if len(s:behavsCurrent) > s:iBehavs
Expand Down
1 change: 1 addition & 0 deletions plugin/acp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ endfunction
call s:defineOption('g:acp_enableAtStartup', 1)
call s:defineOption('g:acp_mappingDriven', 0)
call s:defineOption('g:acp_ignorecaseOption', 1)
call s:defineOption('g:acp_autoselectFirstCompletion', 1)
call s:defineOption('g:acp_completeOption', '.,w,b,k')
call s:defineOption('g:acp_completeoptPreview', 0)
call s:defineOption('g:acp_behaviorUserDefinedFunction', '')
Expand Down