-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add complete_info() function #4106
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
Conversation
Once the specification is decided, refactor, update the document and add more tests.
```
complete_info([{what}])
Returns a Dictionary with information about insert mode
completion. see |ins-completion|.
The items are:
mode current completion mode name string.
See |completion_info_mode| for the values.
pum_visible |TRUE| if popup menu is visible.
See |pumvisible()|.
items List of completion matches. Each item is a
dictionary containing the entries "word",
"abbr", "menu", "kind", "info" and "user_data".
See |complete-items|.
Is this really useful? In some cases this list can be very long,
slowing down the operation.
selected Selected item index. First index is zero.
Set -1 if not selected.
"Index is -1 if no item is selected (showing typed text only)"
[...]
…--
hundred-and-one symptoms of being an internet addict:
49. You never have to deal with busy signals when calling your ISP...because
you never log off.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
I consider this point.
Thanks. I'll reflect later. |
@h-east What is an example of @brammool I think getting |
@prabirshrestha
|
Codecov Report
@@ Coverage Diff @@
## master #4106 +/- ##
==========================================
- Coverage 79.25% 79.25% -0.01%
==========================================
Files 105 105
Lines 141171 141231 +60
==========================================
+ Hits 111892 111933 +41
- Misses 29279 29298 +19
Continue to review full report at Codecov.
|
@prabirshrestha, can you explain further how having the items field would allow a plugin to implement fuzzy search? |
@h-east using empty string seems a bit weird because it is mostly falsy
@andymass function! s:omni_completor(opt, ctx) abort
let mode = complete_info({ 'mode': '' })['mode']
if mode == 'omni'
let items = complete_info({ 'items': '' })['items']
let startcol = col('.')
call asyncomplete#complete(a:opt['name'], a:ctx, startcol, items)
endif
endfunction
call asyncomplete#register_source({
\ 'name': 'omnifunc',
\ 'whitelist': ['*'],
\ 'completor': function('s:omni_completor'),
\ })
function! s:myfuzzy_asyncomplete_preprocessor(ctx, matches) abort
" implement sorting/ranking and fuzzy match on a:matches
" this function is called before asyncomplete.vim shows the popup
call asyncomplete#preprocess_complete(a:ctx, l:items)
endfunction
let g:asyncomplete_preprocessor = [function('s:myfuzzy_asyncomplete_preprocessor')] You would also like to handle pum open autocmd and call v2 also now supports preprocessor which runs right before it shows the menu so you can modify the items. https://github.com/prabirshrestha/asyncomplete.vim/blob/f1cc9e3c9e952c666652152c38089c89471f4e18/doc/asyncomplete.txt#L55-L87 This pre-processor runs in every keystroke so you can easily implement fuzzy find. Asyncomplete also caches the sources based on startcol you don't have to worry about checking complete mode all the time. preprocess api is designed to be future compatible which mean you can call |
@prabirshrestha
Thank you for the suggestion.
I added an example in the document.
```
Examples:
" Get all items
call complete_info()
" Get only 'mode'
call complete_info({'mode': ''})
" Get only 'mode' and 'pum_visible'
call complete_info({'mode': '', 'pum_visible': ''})
```
I don't think it is needed to use a dictionary argument. We can use a
list of strings, that is simpler:
" Get all items
call complete_info()
" Get only 'mode'
call complete_info(['mode'])
" Get only 'mode' and 'pum_visible'
call complete_info(['mode', 'pum_visible'])
…--
hundred-and-one symptoms of being an internet addict:
61. Your best friends know your e-mail address, but neither your phone number
nor the address where you live.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
I had thought of array of string but since I would call this function in every keystroke it would need to be fast. Having said that arrays are still better interms if api. |
@wsdjeg I do not want to waste time with me and Vim developers any more. |
I made it a dictionary because I referred to |
@brammool
> I don't think it is needed to use a dictionary argument. We can use a
list of strings, that is simpler:
[...]
I made it a dictionary because I referred to `{what}` of
`getqflist()`, but the list is good for this API.
The getqflist() function has some arguments with a number value. E.g.
"nr" specifies the quickfix list. For complete_info() I don't think we
would ever have a number value, only a list of items to return.
I think that consistency between these two functions is not relevant.
…--
hundred-and-one symptoms of being an internet addict:
73. You give your dog used motherboards instead of bones
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Hi,
On Sun, Mar 17, 2019 at 6:44 AM Bram Moolenaar ***@***.***> wrote:
> @brammool
> > I don't think it is needed to use a dictionary argument. We can use a
> list of strings, that is simpler:
> [...]
>
> I made it a dictionary because I referred to `{what}` of
> `getqflist()`, but the list is good for this API.
The getqflist() function has some arguments with a number value. E.g.
"nr" specifies the quickfix list. For complete_info() I don't think we
would ever have a number value, only a list of items to return.
Yes. The getqflist() function also accepts values for the following
arguments in {what}:
id quickfix list identifier
lines List of lines to parse
efm Error format to use for parsing the list of lines in 'lines'
nr quickfix list number
As the caller can pass non-zero values for these items, the
getqflist() function uses a Dictionary instead of a List as the
argument type.
- Yegappan
… I think that consistency between these two functions is not relevant.
|
Updated asyncomplete v2 to use the new apis and it works great. prabirshrestha/asyncomplete.vim@623c744 Any chance we can get this PR merged to master soon? |
@brammool (cc: @prabirshrestha ) -- |
@prabirshrestha @brammool If you have opinion about this patch, pleaes let me known. I'll take over the work. |
It is ready to be merged from my side. |
@brammool Any update on this? Any concerns blocking the merge to master? |
…letion Problem: Cannot get all the information about current completion. Solution: Add complete_info(). (Shougo, Hirohito Higashi, closes vim/vim#4106) vim/vim@fd13332
…letion Problem: Cannot get all the information about current completion. Solution: Add complete_info(). (Shougo, Hirohito Higashi, closes vim/vim#4106) vim/vim@fd13332
…letion Problem: Cannot get all the information about current completion. Solution: Add complete_info(). (Shougo, Hirohito Higashi, closes vim/vim#4106) vim/vim@fd13332
Once the specification is decided, refactor, update the document and add more tests.
Related Issue/Thread
#3866
https://groups.google.com/d/msg/vim_dev/6utE1ObSYY8/fOaLtsBUGwAJ
--
Best regards,
Hirohito Higashi (h_east)