mirror of https://github.com/dense-analysis/ale
Add ability to manually trigger completion menu (#2177)
* Add ability to manually trigger completion menu * Mention :ALEComplete in completion docs * Add test for ALEComplete
This commit is contained in:
parent
5bbe77101d
commit
0fcd5e79a9
|
@ -509,6 +509,12 @@ function! ale#completion#GetCompletions() abort
|
|||
return
|
||||
endif
|
||||
|
||||
call ale#completion#AlwaysGetCompletions()
|
||||
endfunction
|
||||
|
||||
" This function can be used to manually trigger autocomplete, even when
|
||||
" g:ale_completion_enabled is set to false
|
||||
function! ale#completion#AlwaysGetCompletions() abort
|
||||
let [l:line, l:column] = getcurpos()[1:2]
|
||||
|
||||
let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column)
|
||||
|
|
14
doc/ale.txt
14
doc/ale.txt
|
@ -821,6 +821,9 @@ with |g:ale_completion_max_suggestions|.
|
|||
If you don't like some of the suggestions you see, you can filter them out
|
||||
with |g:ale_completion_excluded_words| or |b:ale_completion_excluded_words|.
|
||||
|
||||
The |ALEComplete| command can be used to show completion suggestions manually,
|
||||
even when |g:ale_completion_enabled| is set to `0`.
|
||||
|
||||
*ale-completion-completopt-bug*
|
||||
|
||||
ALE implements completion as you type by temporarily adjusting |completeopt|
|
||||
|
@ -2236,6 +2239,17 @@ ALE will use to search for Python executables.
|
|||
===============================================================================
|
||||
8. Commands/Keybinds *ale-commands*
|
||||
|
||||
ALEComplete *ALEComplete*
|
||||
|
||||
Manually trigger LSP autocomplete and show the menu. Works only when called
|
||||
from insert mode. >
|
||||
|
||||
inoremap <silent> <C-Space> <C-\><C-O>:AleComplete<CR>
|
||||
<
|
||||
A plug mapping `<Plug>(ale_complete)` is defined for this command. >
|
||||
|
||||
imap <C-Space> <Plug>(ale_complete)
|
||||
<
|
||||
ALEDocumentation *ALEDocumentation*
|
||||
|
||||
Similar to the |ALEHover| command, retrieve documentation information for
|
||||
|
|
|
@ -204,6 +204,8 @@ command! -bar ALEDocumentation :call ale#hover#ShowDocumentationAtCursor()
|
|||
" Search for appearances of a symbol, such as a type name or function name.
|
||||
command! -nargs=1 ALESymbolSearch :call ale#symbol#Search(<q-args>)
|
||||
|
||||
command! -bar ALEComplete :call ale#completion#AlwaysGetCompletions()
|
||||
|
||||
" <Plug> mappings for commands
|
||||
nnoremap <silent> <Plug>(ale_previous) :ALEPrevious<Return>
|
||||
nnoremap <silent> <Plug>(ale_previous_wrap) :ALEPreviousWrap<Return>
|
||||
|
@ -229,6 +231,7 @@ nnoremap <silent> <Plug>(ale_go_to_definition_in_vsplit) :ALEGoToDefinitionInVSp
|
|||
nnoremap <silent> <Plug>(ale_find_references) :ALEFindReferences<Return>
|
||||
nnoremap <silent> <Plug>(ale_hover) :ALEHover<Return>
|
||||
nnoremap <silent> <Plug>(ale_documentation) :ALEDocumentation<Return>
|
||||
inoremap <silent> <Plug>(ale_complete) <C-\><C-O>:ALEComplete<Return>
|
||||
|
||||
" Set up autocmd groups now.
|
||||
call ale#events#Init()
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
Before:
|
||||
function! MockAlwaysGetCompletions() abort
|
||||
let g:get_completions_called = 0
|
||||
|
||||
function! ale#completion#AlwaysGetCompletions() abort
|
||||
let g:get_completions_called = 1
|
||||
endfunction
|
||||
endfunction
|
||||
|
||||
call MockAlwaysGetCompletions()
|
||||
|
||||
After:
|
||||
unlet! g:get_completions_called
|
||||
delfunction MockAlwaysGetCompletions
|
||||
delfunction ale#completion#AlwaysGetCompletions
|
||||
|
||||
runtime autoload/ale/completion.vim
|
||||
|
||||
Execute(ale#completion#AlwaysGetCompletions should be called when ALEComplete is executed):
|
||||
AssertEqual 0, g:get_completions_called
|
||||
ALEComplete
|
||||
AssertEqual 1, g:get_completions_called
|
Loading…
Reference in New Issue