diff options
author | Jerko Steiner <jerko.steiner@gmail.com> | 2019-01-07 23:23:33 +0100 |
---|---|---|
committer | Jerko Steiner <jerko.steiner@gmail.com> | 2019-01-08 12:57:17 +0100 |
commit | 9bcf8a2336ff6f98e5032d30e17c2671d66946fe (patch) | |
tree | 6b8353b720b656d83084762c3d365468cffadf4c | |
parent | 0fcd5e79a9be71027df6d7e77034d530fa9bf959 (diff) | |
download | ale-9bcf8a2336ff6f98e5032d30e17c2671d66946fe.zip |
Manually trigger autocomplete even when prefix is ""
-rw-r--r-- | autoload/ale/completion.vim | 9 | ||||
-rw-r--r-- | test/completion/test_completion_filtering.vader | 3 |
2 files changed, 8 insertions, 4 deletions
diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim index 3bf29191..b0981f37 100644 --- a/autoload/ale/completion.vim +++ b/autoload/ale/completion.vim @@ -106,7 +106,7 @@ function! ale#completion#Filter(buffer, filetype, suggestions, prefix) abort " foo. " ^ " We need to include all of the given suggestions. - if index(l:triggers, a:prefix) >= 0 + if index(l:triggers, a:prefix) >= 0 || empty(a:prefix) let l:filtered_suggestions = a:suggestions else let l:filtered_suggestions = [] @@ -509,17 +509,18 @@ function! ale#completion#GetCompletions() abort return endif - call ale#completion#AlwaysGetCompletions() + call ale#completion#AlwaysGetCompletions(1) 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 +function! ale#completion#AlwaysGetCompletions(...) abort + let l:need_prefix = get(a:, 1, 0) let [l:line, l:column] = getcurpos()[1:2] let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column) - if empty(l:prefix) + if l:need_prefix && empty(l:prefix) return endif diff --git a/test/completion/test_completion_filtering.vader b/test/completion/test_completion_filtering.vader index ffb313ef..1122ab60 100644 --- a/test/completion/test_completion_filtering.vader +++ b/test/completion/test_completion_filtering.vader @@ -16,6 +16,9 @@ Execute(Prefix filtering should work for Lists of strings): AssertEqual \ ['FooBar', 'FongBar', 'baz', 'foo'], \ ale#completion#Filter(bufnr(''), '', ['FooBar', 'FongBar', 'baz', 'foo'], '.') + AssertEqual + \ ['FooBar', 'FongBar', 'baz', 'foo'], + \ ale#completion#Filter(bufnr(''), '', ['FooBar', 'FongBar', 'baz', 'foo'], '') Execute(Prefix filtering should work for completion items): AssertEqual |