#1700 - Temporarily change completion options when the feedkeys() keybind is fired
This commit is contained in:
parent
4ed35f7247
commit
0012c78b02
@ -1,10 +1,17 @@
|
|||||||
" Author: w0rp <devw0rp@gmail.com>
|
" Author: w0rp <devw0rp@gmail.com>
|
||||||
" Description: Completion support for LSP linters
|
" Description: Completion support for LSP linters
|
||||||
|
|
||||||
|
function! ale#completion#TriggerOmnicompleteMenu() abort
|
||||||
|
" Replace completion options shortly before opening the menu.
|
||||||
|
call s:ReplaceCompletionOptions()
|
||||||
|
|
||||||
|
return "\<C-x>\<C-o>"
|
||||||
|
endfunction
|
||||||
|
|
||||||
" The omnicompletion menu is shown through a special Plug mapping which is
|
" The omnicompletion menu is shown through a special Plug mapping which is
|
||||||
" only valid in Insert mode. This way, feedkeys() won't send these keys if you
|
" only valid in Insert mode. This way, feedkeys() won't send these keys if you
|
||||||
" quit Insert mode quickly enough.
|
" quit Insert mode quickly enough.
|
||||||
inoremap <silent> <Plug>(ale_show_completion_menu) <C-x><C-o>
|
inoremap <silent> <Plug>(ale_show_completion_menu) <C-R>=ale#completion#TriggerOmnicompleteMenu()<CR>
|
||||||
" If we hit the key sequence in normal mode, then we won't show the menu, so
|
" If we hit the key sequence in normal mode, then we won't show the menu, so
|
||||||
" we should restore the old settings right away.
|
" we should restore the old settings right away.
|
||||||
nnoremap <silent> <Plug>(ale_show_completion_menu) :call ale#completion#RestoreCompletionOptions()<CR>
|
nnoremap <silent> <Plug>(ale_show_completion_menu) :call ale#completion#RestoreCompletionOptions()<CR>
|
||||||
@ -214,7 +221,6 @@ function! ale#completion#Show(response, completion_parser) abort
|
|||||||
" function, and then start omni-completion.
|
" function, and then start omni-completion.
|
||||||
let b:ale_completion_response = a:response
|
let b:ale_completion_response = a:response
|
||||||
let b:ale_completion_parser = a:completion_parser
|
let b:ale_completion_parser = a:completion_parser
|
||||||
call s:ReplaceCompletionOptions()
|
|
||||||
call ale#util#FeedKeys("\<Plug>(ale_show_completion_menu)")
|
call ale#util#FeedKeys("\<Plug>(ale_show_completion_menu)")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -125,6 +125,8 @@ Execute(ale#completion#Show() should remember the omnifunc setting and replace i
|
|||||||
let &l:omnifunc = 'FooBar'
|
let &l:omnifunc = 'FooBar'
|
||||||
|
|
||||||
call ale#completion#Show('Response', 'Parser')
|
call ale#completion#Show('Response', 'Parser')
|
||||||
|
AssertEqual [["\<Plug>(ale_show_completion_menu)"]], g:feedkeys_calls
|
||||||
|
call ale#completion#TriggerOmnicompleteMenu()
|
||||||
|
|
||||||
AssertEqual 'FooBar', b:ale_old_omnifunc
|
AssertEqual 'FooBar', b:ale_old_omnifunc
|
||||||
AssertEqual 'ale#completion#OmniFunc', &l:omnifunc
|
AssertEqual 'ale#completion#OmniFunc', &l:omnifunc
|
||||||
@ -133,6 +135,8 @@ Execute(ale#completion#Show() should remember the completeopt setting and replac
|
|||||||
let &l:completeopt = 'menu'
|
let &l:completeopt = 'menu'
|
||||||
|
|
||||||
call ale#completion#Show('Response', 'Parser')
|
call ale#completion#Show('Response', 'Parser')
|
||||||
|
AssertEqual [["\<Plug>(ale_show_completion_menu)"]], g:feedkeys_calls
|
||||||
|
call ale#completion#TriggerOmnicompleteMenu()
|
||||||
|
|
||||||
AssertEqual 'menu', b:ale_old_completopt
|
AssertEqual 'menu', b:ale_old_completopt
|
||||||
AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt
|
AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt
|
||||||
@ -141,6 +145,8 @@ Execute(ale#completion#Show() should set the preview option if it's set):
|
|||||||
let &l:completeopt = 'menu,preview'
|
let &l:completeopt = 'menu,preview'
|
||||||
|
|
||||||
call ale#completion#Show('Response', 'Parser')
|
call ale#completion#Show('Response', 'Parser')
|
||||||
|
AssertEqual [["\<Plug>(ale_show_completion_menu)"]], g:feedkeys_calls
|
||||||
|
call ale#completion#TriggerOmnicompleteMenu()
|
||||||
|
|
||||||
AssertEqual 'menu,preview', b:ale_old_completopt
|
AssertEqual 'menu,preview', b:ale_old_completopt
|
||||||
AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt
|
AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user