diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim index 332d0734..4cf3a51a 100644 --- a/autoload/ale/completion.vim +++ b/autoload/ale/completion.vim @@ -269,13 +269,19 @@ function! s:ReplaceCompletionOptions(source) abort let b:ale_old_completeopt = &l:completeopt endif - if &l:completeopt =~# 'preview' - let &l:completeopt = 'menu,menuone,preview,noselect,noinsert' - elseif &l:completeopt =~# 'popup' - let &l:completeopt = 'menu,menuone,popup,noselect,noinsert' - else - let &l:completeopt = 'menu,menuone,noselect,noinsert' - endif + let l:opt_list = split(&l:completeopt, ',') + " The menu and noinsert options must be set, or automatic completion + " will be annoying. + let l:new_opt_list = ['menu', 'menuone', 'noinsert'] + + " Permit some other completion options, provided users have set them. + for l:opt in ['preview', 'popup', 'noselect'] + if index(l:opt_list, l:opt) >= 0 + call add(l:new_opt_list, l:opt) + endif + endfor + + let &l:completeopt = join(l:new_opt_list, ',') endif endfunction diff --git a/doc/ale.txt b/doc/ale.txt index 9ff05059..62881503 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -561,7 +561,6 @@ vimrc, and your issues should go away. > set completeopt=menu,menuone,preview,noselect,noinsert < - Or alternatively, if you want to show documentation in popups: > set completeopt=menu,menuone,popup,noselect,noinsert diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader index 1b760e2c..ed6dbea3 100644 --- a/test/completion/test_completion_events.vader +++ b/test/completion/test_completion_events.vader @@ -172,7 +172,7 @@ Execute(ale#completion#Show() should remember the completeopt setting and replac call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) AssertEqual 'menu', b:ale_old_completeopt - AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt + AssertEqual 'menu,menuone,noinsert', &l:completeopt AssertEqual [], g:feedkeys_calls sleep 1ms @@ -185,7 +185,7 @@ Execute(ale#completion#Show() should set the preview option if it's set): call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) AssertEqual 'menu,preview', b:ale_old_completeopt - AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt + AssertEqual 'menu,menuone,noinsert,preview', &l:completeopt AssertEqual [], g:feedkeys_calls sleep 1ms @@ -205,13 +205,13 @@ Execute(ale#completion#Show() should not replace the completeopt setting for man AssertEqual [["\(ale_show_completion_menu)"]], g:feedkeys_calls Execute(ale#completion#AutomaticOmniFunc() should also remember the completeopt setting and replace it): - let &l:completeopt = 'menu' + let &l:completeopt = 'menu,noselect' let b:ale_completion_info = {'source': 'ale-automatic'} call ale#completion#AutomaticOmniFunc(0, '') - AssertEqual 'menu', b:ale_old_completeopt - AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt + AssertEqual 'menu,noselect', b:ale_old_completeopt + AssertEqual 'menu,menuone,noinsert,noselect', &l:completeopt Execute(ale#completion#AutomaticOmniFunc() should set the preview option if it's set): let &l:completeopt = 'menu,preview' @@ -220,7 +220,7 @@ Execute(ale#completion#AutomaticOmniFunc() should set the preview option if it's call ale#completion#AutomaticOmniFunc(0, '') AssertEqual 'menu,preview', b:ale_old_completeopt - AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt + AssertEqual 'menu,menuone,noinsert,preview', &l:completeopt Execute(ale#completion#Show() should make the correct feedkeys() call for automatic completion): let b:ale_completion_info = {'source': 'ale-automatic'}